From 2c9241003656e8edde40b21e0851e032cc391364 Mon Sep 17 00:00:00 2001 From: Timo Glastra Date: Wed, 9 Jun 2021 16:48:50 +0200 Subject: [PATCH] style: enforce import ordering (#311) --- .eslintrc.js | 16 ++ package.json | 3 +- src/__tests__/agents.test.ts | 4 +- src/__tests__/credentials.test.ts | 21 ++- src/__tests__/helpers.ts | 12 +- src/__tests__/ledger.test.ts | 4 +- src/__tests__/logger.ts | 3 +- src/__tests__/proofs.test.ts | 26 +-- src/agent/Agent.ts | 27 +-- src/agent/AgentConfig.ts | 1 + src/agent/AgentMessage.ts | 13 +- src/agent/BaseMessage.ts | 2 +- src/agent/Dispatcher.ts | 10 +- src/agent/EnvelopeService.ts | 8 +- src/agent/EventEmitter.ts | 3 +- src/agent/Handler.ts | 1 + src/agent/MessageReceiver.ts | 19 +- src/agent/MessageSender.ts | 9 +- src/agent/TransportService.ts | 4 +- src/agent/__tests__/Agent.test.ts | 26 +-- src/agent/__tests__/AgentConfig.test.ts | 2 +- src/agent/__tests__/MessageSender.test.ts | 18 +- src/agent/__tests__/TransportService.test.ts | 2 +- src/agent/helpers.ts | 8 +- src/agent/models/InboundMessageContext.ts | 3 +- src/decorators/ack/AckDecorator.test.ts | 2 +- src/decorators/ack/AckDecoratorExtension.ts | 1 + src/decorators/attachment/Attachment.test.ts | 1 + src/decorators/attachment/Attachment.ts | 1 + .../attachment/AttachmentExtension.ts | 1 + src/decorators/l10n/L10nDecoratorExtension.ts | 1 + .../signature/SignatureDecoratorUtils.test.ts | 7 +- .../signature/SignatureDecoratorUtils.ts | 12 +- src/decorators/thread/ThreadDecorator.test.ts | 1 + src/decorators/thread/ThreadDecorator.ts | 1 + .../thread/ThreadDecoratorExtension.ts | 1 + src/decorators/timing/TimingDecorator.test.ts | 1 + .../timing/TimingDecoratorExtension.ts | 1 + .../transport/TransportDecorator.test.ts | 4 +- .../transport/TransportDecoratorExtension.ts | 4 +- src/logger/BaseLogger.ts | 2 + .../basic-messages/BasicMessageEvents.ts | 2 + .../basic-messages/BasicMessagesModule.ts | 5 +- .../__tests__/BasicMessageService.test.ts | 20 +- .../handlers/BasicMessageHandler.ts | 4 +- .../basic-messages/messages/BasicMessage.ts | 3 +- .../repository/BasicMessageRecord.ts | 2 +- .../repository/BasicMessageRepository.ts | 3 +- .../services/BasicMessageService.ts | 10 +- src/modules/common/messages/AckMessage.ts | 1 + src/modules/connections/ConnectionEvents.ts | 3 +- src/modules/connections/ConnectionsModule.ts | 9 +- .../ConnectionInvitationMessage.test.ts | 2 +- .../__tests__/ConnectionService.test.ts | 25 +-- .../connections/handlers/AckMessageHandler.ts | 2 +- .../handlers/ConnectionRequestHandler.ts | 6 +- .../handlers/ConnectionResponseHandler.ts | 6 +- .../handlers/TrustPingMessageHandler.ts | 8 +- .../TrustPingResponseMessageHandler.ts | 2 +- .../messages/ConnectionInvitationMessage.ts | 1 + .../messages/ConnectionRequestMessage.ts | 3 +- .../messages/ConnectionResponseMessage.ts | 5 +- .../connections/messages/TrustPingMessage.ts | 5 +- .../messages/TrustPingResponseMessage.ts | 3 +- src/modules/connections/models/Connection.ts | 2 +- .../did/__tests__/Authentication.test.ts | 1 + .../models/did/__tests__/DidDoc.test.ts | 2 +- .../models/did/__tests__/PublicKey.test.ts | 2 + .../models/did/__tests__/Service.test.ts | 1 + .../authentication/EmbeddedAuthentication.ts | 2 + .../ReferencedAuthentication.ts | 2 + .../models/did/authentication/index.ts | 3 +- .../models/did/publicKey/Ed25119Sig2018.ts | 1 + .../did/publicKey/EddsaSaSigSecp256k1.ts | 1 + .../models/did/publicKey/RsaSig2018.ts | 1 + .../connections/models/did/publicKey/index.ts | 2 +- .../models/did/service/DidCommService.ts | 1 + .../models/did/service/IndyAgentService.ts | 1 + .../connections/models/did/service/index.ts | 2 +- .../repository/ConnectionRecord.ts | 13 +- .../repository/ConnectionRepository.ts | 3 +- .../connections/services/ConnectionService.ts | 32 ++-- .../connections/services/TrustPingService.ts | 2 +- src/modules/credentials/CredentialEvents.ts | 1 + src/modules/credentials/CredentialUtils.ts | 24 +-- src/modules/credentials/CredentialsModule.ts | 13 +- .../__tests__/CredentialRecord.test.ts | 2 +- .../__tests__/CredentialService.test.ts | 39 ++-- .../__tests__/CredentialUtils.test.ts | 6 +- .../credentials/__tests__/StubWallet.ts | 3 +- .../handlers/CredentialAckHandler.ts | 2 +- .../handlers/IssueCredentialHandler.ts | 2 +- .../handlers/OfferCredentialHandler.ts | 2 +- .../handlers/ProposeCredentialHandler.ts | 2 +- .../handlers/RequestCredentialHandler.ts | 2 +- .../messages/CredentialAckMessage.ts | 3 +- .../credentials/messages/CredentialPreview.ts | 1 + .../messages/IssueCredentialMessage.ts | 3 +- .../messages/OfferCredentialMessage.ts | 9 +- .../messages/ProposeCredentialMessage.ts | 1 + .../messages/RequestCredentialMessage.ts | 8 +- src/modules/credentials/models/Credential.ts | 3 +- .../credentials/models/IndyCredentialInfo.ts | 2 +- .../repository/CredentialRecord.ts | 7 +- .../repository/CredentialRepository.ts | 3 +- .../credentials/services/CredentialService.ts | 27 ++- .../indy/services/IndyIssuerService.ts | 2 +- src/modules/ledger/LedgerModule.ts | 7 +- src/modules/ledger/services/LedgerService.ts | 9 +- src/modules/proofs/ProofEvents.ts | 1 + src/modules/proofs/ProofsModule.ts | 17 +- .../proofs/handlers/PresentationAckHandler.ts | 2 +- .../proofs/messages/PresentationAckMessage.ts | 1 + .../proofs/messages/PresentationMessage.ts | 5 +- .../proofs/messages/PresentationPreview.ts | 5 +- .../messages/ProposePresentationMessage.ts | 3 +- .../messages/RequestPresentationMessage.ts | 3 +- src/modules/proofs/models/ProofAttribute.ts | 2 +- .../proofs/models/ProofAttributeInfo.ts | 3 +- .../proofs/models/ProofPredicateInfo.ts | 3 +- src/modules/proofs/models/ProofRequest.ts | 12 +- .../proofs/models/RequestedAttribute.ts | 2 +- .../proofs/models/RequestedCredentials.ts | 9 +- .../proofs/models/RequestedPredicate.ts | 2 +- src/modules/proofs/models/RequestedProof.ts | 2 +- src/modules/proofs/repository/ProofRecord.ts | 6 +- .../proofs/repository/ProofRepository.ts | 3 +- src/modules/proofs/services/ProofService.ts | 31 ++-- src/modules/routing/RoutingModule.ts | 17 +- src/modules/routing/handlers/BatchHandler.ts | 1 - .../routing/handlers/BatchPickupHandler.ts | 4 +- .../routing/handlers/ForwardHandler.ts | 2 +- .../routing/handlers/KeylistUpdateHandler.ts | 4 +- .../handlers/KeylistUpdateResponseHandler.ts | 4 +- src/modules/routing/messages/BatchMessage.ts | 9 +- .../routing/messages/BatchPickupMessage.ts | 3 +- .../routing/messages/ForwardMessage.ts | 3 +- .../routing/messages/KeylistUpdateMessage.ts | 5 +- .../messages/KeylistUpdateResponseMessage.ts | 7 +- .../routing/repository/ProvisioningRecord.ts | 2 +- .../repository/ProvisioningRepository.ts | 3 +- .../services/ConsumerRoutingService.ts | 4 +- .../routing/services/MessagePickupService.ts | 6 +- .../services/ProviderRoutingService.ts | 6 +- .../routing/services/ProvisioningService.ts | 8 +- src/storage/InMemoryMessageRepository.ts | 5 +- src/storage/IndyStorageService.ts | 14 +- src/storage/MessageRepository.ts | 1 + src/storage/Repository.ts | 1 + src/storage/StorageService.ts | 1 + .../__tests__/IndyStorageService.test.ts | 7 +- src/storage/__tests__/Repository.test.ts | 7 +- src/storage/fs/NodeFileSystem.ts | 3 +- src/storage/fs/ReactNativeFileSystem.ts | 1 + src/transport/HttpOutboundTransporter.ts | 7 +- src/transport/OutboundTransporter.ts | 1 + src/transport/WsOutboundTransporter.ts | 6 +- src/types.ts | 7 +- src/utils/HashlinkEncoder.ts | 3 +- src/utils/MultibaseEncoder.ts | 2 - src/utils/MultihashEncoder.ts | 1 - src/utils/__tests__/HashlinkEncoder.test.ts | 1 + src/utils/__tests__/MultibaseEncoder.test.ts | 3 +- src/utils/__tests__/MultihashEncoder.test.ts | 3 +- src/utils/indyError.ts | 3 + src/utils/transformers.ts | 2 + src/wallet/IndyWallet.ts | 13 +- src/wallet/Wallet.test.ts | 5 +- src/wallet/Wallet.ts | 1 + tests/__tests__/e2e-ws.test.ts | 2 +- tests/__tests__/e2e.test.ts | 2 +- tests/config.ts | 7 +- tests/http.ts | 1 + tests/mediator-ws.ts | 24 ++- tests/mediator.ts | 18 +- types/jest.d.ts | 5 +- yarn.lock | 173 +++++++++++++++++- 177 files changed, 757 insertions(+), 446 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index daa22cac0f..3c1bb675d7 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -2,9 +2,14 @@ module.exports = { parser: '@typescript-eslint/parser', extends: [ 'eslint:recommended', + 'plugin:import/recommended', + 'plugin:import/typescript', 'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin 'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array. ], + settings: { + 'import/extensions': ['.js', '.ts'], + }, plugins: ['@typescript-eslint'], rules: { // Type is enforced by callers. Not entirely, but it's good enough. @@ -17,12 +22,23 @@ module.exports = { 'no-console': 'error', // Because of early development, we only warn on ts-ignore. In future we want to move to error '@typescript-eslint/ban-ts-comment': 'warn', + 'import/order': [ + 'error', + { + groups: [['builtin', 'external'], 'parent', 'sibling', 'index'], + alphabetize: { + order: 'asc', + }, + 'newlines-between': 'always', + }, + ], }, overrides: [ { files: ['*.test.*'], rules: { 'no-console': 'off', + '@typescript-eslint/no-non-null-assertion': 'off', }, }, { diff --git a/package.json b/package.json index bf2af5f17a..75ed30ea9e 100644 --- a/package.json +++ b/package.json @@ -35,9 +35,9 @@ "class-validator": "^0.13.1", "events": "^3.3.0", "js-sha256": "^0.9.0", + "make-error": "^1.3.6", "multibase": "4.0.2", "multihashes": "^4.0.2", - "make-error": "^1.3.6", "node-fetch": "^2.6.1", "object-inspect": "^1.10.3", "react-native-fs": "^2.18.0", @@ -62,6 +62,7 @@ "dotenv": "^8.2.0", "eslint": "^7.21.0", "eslint-config-prettier": "^8.1.0", + "eslint-plugin-import": "^2.23.4", "eslint-plugin-prettier": "^3.3.1", "express": "^4.17.1", "husky": "^5.1.3", diff --git a/src/__tests__/agents.test.ts b/src/__tests__/agents.test.ts index 1dcdeaa10d..f4b73654f8 100644 --- a/src/__tests__/agents.test.ts +++ b/src/__tests__/agents.test.ts @@ -1,8 +1,10 @@ import { Subject } from 'rxjs' + import { Agent } from '..' -import { SubjectInboundTransporter, SubjectOutboundTransporter, waitForBasicMessage, getBaseConfig } from './helpers' import { ConnectionRecord } from '../modules/connections' +import { SubjectInboundTransporter, SubjectOutboundTransporter, waitForBasicMessage, getBaseConfig } from './helpers' + const aliceConfig = getBaseConfig('Agents Alice') const bobConfig = getBaseConfig('Agents Bob') diff --git a/src/__tests__/credentials.test.ts b/src/__tests__/credentials.test.ts index 1bf2b02169..647a27e3c2 100644 --- a/src/__tests__/credentials.test.ts +++ b/src/__tests__/credentials.test.ts @@ -1,5 +1,15 @@ import { Subject } from 'rxjs' -import { Agent, ConnectionRecord } from '..' + +import { Agent } from '../agent/Agent' +import { ConnectionRecord } from '../modules/connections' +import { + CredentialRecord, + CredentialState, + CredentialPreview, + CredentialPreviewAttribute, +} from '../modules/credentials' +import { JsonTransformer } from '../utils/JsonTransformer' + import { ensurePublicDidIsOnLedger, makeConnection, @@ -11,14 +21,6 @@ import { genesisPath, getBaseConfig, } from './helpers' -import { - CredentialRecord, - CredentialState, - CredentialPreview, - CredentialPreviewAttribute, -} from '../modules/credentials' -import { JsonTransformer } from '../utils/JsonTransformer' - import testLogger from './logger' const faberConfig = getBaseConfig('Faber Credentials', { @@ -86,6 +88,7 @@ describe('credentials', () => { credDefId = credentialDefinition.id const publicDid = faberAgent.publicDid?.did + await ensurePublicDidIsOnLedger(faberAgent, publicDid!) const { agentAConnection, agentBConnection } = await makeConnection(faberAgent, aliceAgent) faberConnection = agentAConnection diff --git a/src/__tests__/helpers.ts b/src/__tests__/helpers.ts index 31fff4f728..bef7821c6d 100644 --- a/src/__tests__/helpers.ts +++ b/src/__tests__/helpers.ts @@ -2,8 +2,9 @@ import type { Schema, CredDef, Did } from 'indy-sdk' import indy from 'indy-sdk' import path from 'path' import { Subject } from 'rxjs' + import { Agent, InboundTransporter, OutboundTransporter } from '..' -import { InitConfig, OutboundPackage, WireMessage } from '../types' +import { BasicMessage, BasicMessageEventTypes, BasicMessageReceivedEvent } from '../modules/basic-messages' import { ConnectionInvitationMessage, ConnectionRecord, @@ -13,8 +14,6 @@ import { DidCommService, DidDoc, } from '../modules/connections' -import { ProofEventTypes, ProofRecord, ProofState, ProofStateChangedEvent } from '../modules/proofs' -import { SchemaTemplate, CredentialDefinitionTemplate } from '../modules/ledger' import { CredentialRecord, CredentialOfferTemplate, @@ -22,9 +21,12 @@ import { CredentialState, CredentialEventTypes, } from '../modules/credentials' -import { BasicMessage, BasicMessageEventTypes, BasicMessageReceivedEvent } from '../modules/basic-messages' -import testLogger from './logger' +import { SchemaTemplate, CredentialDefinitionTemplate } from '../modules/ledger' +import { ProofEventTypes, ProofRecord, ProofState, ProofStateChangedEvent } from '../modules/proofs' import { NodeFileSystem } from '../storage/fs/NodeFileSystem' +import { InitConfig, OutboundPackage, WireMessage } from '../types' + +import testLogger from './logger' export const genesisPath = process.env.GENESIS_TXN_PATH ? path.resolve(process.env.GENESIS_TXN_PATH) diff --git a/src/__tests__/ledger.test.ts b/src/__tests__/ledger.test.ts index 15b2b93e94..47d13a9dbf 100644 --- a/src/__tests__/ledger.test.ts +++ b/src/__tests__/ledger.test.ts @@ -1,10 +1,12 @@ +import { promises } from 'fs' import indy from 'indy-sdk' import type { SchemaId } from 'indy-sdk' + import { Agent } from '..' import { DID_IDENTIFIER_REGEX, VERKEY_REGEX, isFullVerkey, isAbbreviatedVerkey } from '../utils/did' + import { genesisPath, getBaseConfig, sleep } from './helpers' import testLogger from './logger' -import { promises } from 'fs' const faberConfig = getBaseConfig('Faber Ledger', { genesisPath }) diff --git a/src/__tests__/logger.ts b/src/__tests__/logger.ts index 8787f12e5f..c1105e36ca 100644 --- a/src/__tests__/logger.ts +++ b/src/__tests__/logger.ts @@ -1,9 +1,10 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ +import { appendFileSync } from 'fs' import { ILogObject, Logger } from 'tslog' + import { LogLevel } from '../logger' import { BaseLogger } from '../logger/BaseLogger' -import { appendFileSync } from 'fs' function logToTransport(logObject: ILogObject) { appendFileSync('logs.txt', JSON.stringify(logObject) + '\n') diff --git a/src/__tests__/proofs.test.ts b/src/__tests__/proofs.test.ts index cb695028c6..58544c9130 100644 --- a/src/__tests__/proofs.test.ts +++ b/src/__tests__/proofs.test.ts @@ -1,6 +1,20 @@ import type { CredDefId } from 'indy-sdk' import { Subject } from 'rxjs' + import { Agent } from '..' +import { ConnectionRecord } from '../modules/connections' +import { CredentialPreview, CredentialPreviewAttribute } from '../modules/credentials' +import { + PredicateType, + PresentationPreview, + PresentationPreviewAttribute, + PresentationPreviewPredicate, + ProofState, + ProofAttributeInfo, + AttributeFilter, + ProofPredicateInfo, +} from '../modules/proofs' + import { ensurePublicDidIsOnLedger, makeConnection, @@ -13,18 +27,6 @@ import { waitForProofRecord, getBaseConfig, } from './helpers' -import { CredentialPreview, CredentialPreviewAttribute } from '../modules/credentials' -import { - PredicateType, - PresentationPreview, - PresentationPreviewAttribute, - PresentationPreviewPredicate, - ProofState, - ProofAttributeInfo, - AttributeFilter, - ProofPredicateInfo, -} from '../modules/proofs' -import { ConnectionRecord } from '../modules/connections' import testLogger from './logger' const faberConfig = getBaseConfig('Faber Proofs', { genesisPath }) diff --git a/src/agent/Agent.ts b/src/agent/Agent.ts index 1f9bb3669e..2baeabf0b7 100644 --- a/src/agent/Agent.ts +++ b/src/agent/Agent.ts @@ -1,27 +1,28 @@ import { container as baseContainer, DependencyContainer } from 'tsyringe' import { Logger } from '../logger' -import { InitConfig } from '../types' -import { IndyWallet } from '../wallet/IndyWallet' -import { MessageReceiver } from './MessageReceiver' -import { MessageSender } from './MessageSender' -import { InboundTransporter } from '../transport/InboundTransporter' -import { OutboundTransporter } from '../transport/OutboundTransporter' -import { MessageRepository } from '../storage/MessageRepository' -import { IndyStorageService } from '../storage/IndyStorageService' -import { AgentConfig } from './AgentConfig' -import { Wallet } from '../wallet/Wallet' +import { BasicMessagesModule } from '../modules/basic-messages/BasicMessagesModule' import { ConnectionsModule } from '../modules/connections/ConnectionsModule' import { CredentialsModule } from '../modules/credentials/CredentialsModule' +import { LedgerModule } from '../modules/ledger/LedgerModule' import { ProofsModule } from '../modules/proofs/ProofsModule' import { RoutingModule } from '../modules/routing/RoutingModule' -import { BasicMessagesModule } from '../modules/basic-messages/BasicMessagesModule' -import { LedgerModule } from '../modules/ledger/LedgerModule' import { InMemoryMessageRepository } from '../storage/InMemoryMessageRepository' +import { IndyStorageService } from '../storage/IndyStorageService' +import { MessageRepository } from '../storage/MessageRepository' import { Symbols } from '../symbols' -import { TransportSession } from './TransportService' +import { InboundTransporter } from '../transport/InboundTransporter' +import { OutboundTransporter } from '../transport/OutboundTransporter' +import { InitConfig } from '../types' +import { IndyWallet } from '../wallet/IndyWallet' +import { Wallet } from '../wallet/Wallet' + +import { AgentConfig } from './AgentConfig' import { EventEmitter } from './EventEmitter' import { AgentEventTypes, AgentMessageReceivedEvent } from './Events' +import { MessageReceiver } from './MessageReceiver' +import { MessageSender } from './MessageSender' +import { TransportSession } from './TransportService' export class Agent { protected agentConfig: AgentConfig diff --git a/src/agent/AgentConfig.ts b/src/agent/AgentConfig.ts index 197140bf7b..aa4f96f3a6 100644 --- a/src/agent/AgentConfig.ts +++ b/src/agent/AgentConfig.ts @@ -1,5 +1,6 @@ import { ConsoleLogger, Logger, LogLevel } from '../logger' import { InitConfig, InboundConnection, DidCommMimeType } from '../types' + import { DID_COMM_TRANSPORT_QUEUE } from './TransportService' export class AgentConfig { diff --git a/src/agent/AgentMessage.ts b/src/agent/AgentMessage.ts index 49c941b455..bc443cab25 100644 --- a/src/agent/AgentMessage.ts +++ b/src/agent/AgentMessage.ts @@ -1,12 +1,13 @@ -import { Compose } from '../utils/mixins' -import { ThreadDecorated } from '../decorators/thread/ThreadDecoratorExtension' +import { AckDecorated } from '../decorators/ack/AckDecoratorExtension' +import { AttachmentDecorated } from '../decorators/attachment/AttachmentExtension' import { L10nDecorated } from '../decorators/l10n/L10nDecoratorExtension' -import { TransportDecorated } from '../decorators/transport/TransportDecoratorExtension' +import { ThreadDecorated } from '../decorators/thread/ThreadDecoratorExtension' import { TimingDecorated } from '../decorators/timing/TimingDecoratorExtension' -import { BaseMessage } from './BaseMessage' +import { TransportDecorated } from '../decorators/transport/TransportDecoratorExtension' import { JsonTransformer } from '../utils/JsonTransformer' -import { AckDecorated } from '../decorators/ack/AckDecoratorExtension' -import { AttachmentDecorated } from '../decorators/attachment/AttachmentExtension' +import { Compose } from '../utils/mixins' + +import { BaseMessage } from './BaseMessage' const DefaultDecorators = [ ThreadDecorated, diff --git a/src/agent/BaseMessage.ts b/src/agent/BaseMessage.ts index 37f94a226a..03e6c28970 100644 --- a/src/agent/BaseMessage.ts +++ b/src/agent/BaseMessage.ts @@ -1,8 +1,8 @@ import { Expose } from 'class-transformer' import { Matches } from 'class-validator' -import { uuid } from '../utils/uuid' import { Constructor } from '../utils/mixins' +import { uuid } from '../utils/uuid' export const MessageIdRegExp = /[-_./a-zA-Z0-9]{8,64}/ export const MessageTypeRegExp = /(.*?)([a-z0-9._-]+)\/(\d[^/]*)\/([a-z0-9._-]+)$/ diff --git a/src/agent/Dispatcher.ts b/src/agent/Dispatcher.ts index 373ca82776..37d1634c3e 100644 --- a/src/agent/Dispatcher.ts +++ b/src/agent/Dispatcher.ts @@ -1,12 +1,14 @@ import { Lifecycle, scoped } from 'tsyringe' + +import { ReturnRouteTypes } from '../decorators/transport/TransportDecorator' +import { AriesFrameworkError } from '../error/AriesFrameworkError' import { OutboundMessage, OutboundPackage } from '../types' + +import { AgentMessage } from './AgentMessage' import { Handler } from './Handler' import { MessageSender } from './MessageSender' -import { AgentMessage } from './AgentMessage' -import { InboundMessageContext } from './models/InboundMessageContext' -import { ReturnRouteTypes } from '../decorators/transport/TransportDecorator' import { TransportService } from './TransportService' -import { AriesFrameworkError } from '../error/AriesFrameworkError' +import { InboundMessageContext } from './models/InboundMessageContext' @scoped(Lifecycle.ContainerScoped) class Dispatcher { diff --git a/src/agent/EnvelopeService.ts b/src/agent/EnvelopeService.ts index 59bd3925b0..10a3214e6f 100644 --- a/src/agent/EnvelopeService.ts +++ b/src/agent/EnvelopeService.ts @@ -1,10 +1,12 @@ import { inject, scoped, Lifecycle } from 'tsyringe' + +import { Logger } from '../logger' +import { ForwardMessage } from '../modules/routing/messages' +import { Symbols } from '../symbols' import { OutboundMessage, UnpackedMessageContext } from '../types' import { Wallet } from '../wallet/Wallet' -import { ForwardMessage } from '../modules/routing/messages' + import { AgentConfig } from './AgentConfig' -import { Logger } from '../logger' -import { Symbols } from '../symbols' @scoped(Lifecycle.ContainerScoped) class EnvelopeService { diff --git a/src/agent/EventEmitter.ts b/src/agent/EventEmitter.ts index 61b70e359f..396da9e4a9 100644 --- a/src/agent/EventEmitter.ts +++ b/src/agent/EventEmitter.ts @@ -1,5 +1,6 @@ -import { Lifecycle, scoped } from 'tsyringe' import { EventEmitter as NativeEventEmitter } from 'events' +import { Lifecycle, scoped } from 'tsyringe' + import { BaseEvent } from './Events' @scoped(Lifecycle.ContainerScoped) diff --git a/src/agent/Handler.ts b/src/agent/Handler.ts index 1bbb9dc0dc..ae22995ce6 100644 --- a/src/agent/Handler.ts +++ b/src/agent/Handler.ts @@ -1,4 +1,5 @@ import { OutboundMessage } from '../types' + import { AgentMessage } from './AgentMessage' import { InboundMessageContext } from './models/InboundMessageContext' diff --git a/src/agent/MessageReceiver.ts b/src/agent/MessageReceiver.ts index c20a83ee98..a47d820929 100644 --- a/src/agent/MessageReceiver.ts +++ b/src/agent/MessageReceiver.ts @@ -1,18 +1,19 @@ import { Lifecycle, scoped } from 'tsyringe' -import { AgentConfig } from './AgentConfig' -import { Dispatcher } from './Dispatcher' -import { EnvelopeService } from './EnvelopeService' -import { UnpackedMessageContext, UnpackedMessage } from '../types' -import { InboundMessageContext } from './models/InboundMessageContext' -import { RoutingMessageType as MessageType } from '../modules/routing' +import { AriesFrameworkError } from '../error' +import { Logger } from '../logger' import { ConnectionService } from '../modules/connections' -import { AgentMessage } from './AgentMessage' +import { RoutingMessageType as MessageType } from '../modules/routing' +import { UnpackedMessageContext, UnpackedMessage } from '../types' import { JsonTransformer } from '../utils/JsonTransformer' -import { Logger } from '../logger' import { replaceLegacyDidSovPrefixOnMessage } from '../utils/messageType' + +import { AgentConfig } from './AgentConfig' +import { AgentMessage } from './AgentMessage' +import { Dispatcher } from './Dispatcher' +import { EnvelopeService } from './EnvelopeService' import { TransportSession, TransportService } from './TransportService' -import { AriesFrameworkError } from '../error' +import { InboundMessageContext } from './models/InboundMessageContext' @scoped(Lifecycle.ContainerScoped) export class MessageReceiver { diff --git a/src/agent/MessageSender.ts b/src/agent/MessageSender.ts index bbaf76e864..a94d2f8cfe 100644 --- a/src/agent/MessageSender.ts +++ b/src/agent/MessageSender.ts @@ -1,12 +1,13 @@ import { inject, Lifecycle, scoped } from 'tsyringe' -import { OutboundMessage, OutboundPackage } from '../types' -import { OutboundTransporter } from '../transport/OutboundTransporter' -import { EnvelopeService } from './EnvelopeService' -import { TransportService } from './TransportService' import { AriesFrameworkError } from '../error' import { Logger } from '../logger' import { Symbols } from '../symbols' +import { OutboundTransporter } from '../transport/OutboundTransporter' +import { OutboundMessage, OutboundPackage } from '../types' + +import { EnvelopeService } from './EnvelopeService' +import { TransportService } from './TransportService' @scoped(Lifecycle.ContainerScoped) export class MessageSender { diff --git a/src/agent/TransportService.ts b/src/agent/TransportService.ts index 99630f08a3..3d3165f602 100644 --- a/src/agent/TransportService.ts +++ b/src/agent/TransportService.ts @@ -1,10 +1,10 @@ import { Lifecycle, scoped, inject } from 'tsyringe' +import { AriesFrameworkError } from '../error' import { Logger } from '../logger' -import { ConnectionRecord } from '../modules/connections/repository' import { ConnectionRole } from '../modules/connections/models' +import { ConnectionRecord } from '../modules/connections/repository' import { Symbols } from '../symbols' -import { AriesFrameworkError } from '../error' export const DID_COMM_TRANSPORT_QUEUE = 'didcomm:transport/queue' diff --git a/src/agent/__tests__/Agent.test.ts b/src/agent/__tests__/Agent.test.ts index 4926e9a6e4..287ea720c1 100644 --- a/src/agent/__tests__/Agent.test.ts +++ b/src/agent/__tests__/Agent.test.ts @@ -1,30 +1,30 @@ -import { Agent } from '../Agent' -import { ConnectionsModule } from '../../modules/connections/ConnectionsModule' -import { ProofsModule } from '../../modules/proofs/ProofsModule' -import { CredentialsModule } from '../../modules/credentials/CredentialsModule' +import { getBaseConfig } from '../../__tests__/helpers' +import { BasicMessageRepository, BasicMessageService } from '../../modules/basic-messages' import { BasicMessagesModule } from '../../modules/basic-messages/BasicMessagesModule' -import { RoutingModule } from '../../modules/routing/RoutingModule' -import { LedgerModule } from '../../modules/ledger/LedgerModule' import { ConnectionRepository, ConnectionService, TrustPingService } from '../../modules/connections' -import { BasicMessageRepository, BasicMessageService } from '../../modules/basic-messages' +import { ConnectionsModule } from '../../modules/connections/ConnectionsModule' import { CredentialRepository, CredentialService } from '../../modules/credentials' -import { ProofRepository, ProofService } from '../../modules/proofs' +import { CredentialsModule } from '../../modules/credentials/CredentialsModule' import { LedgerService } from '../../modules/ledger' -import { Symbols } from '../../symbols' +import { LedgerModule } from '../../modules/ledger/LedgerModule' +import { ProofRepository, ProofService } from '../../modules/proofs' +import { ProofsModule } from '../../modules/proofs/ProofsModule' import { ConsumerRoutingService, ProviderRoutingService, ProvisioningRepository, ProvisioningService, } from '../../modules/routing' -import { IndyWallet } from '../../wallet/IndyWallet' +import { RoutingModule } from '../../modules/routing/RoutingModule' import { InMemoryMessageRepository } from '../../storage/InMemoryMessageRepository' import { IndyStorageService } from '../../storage/IndyStorageService' -import { MessageSender } from '../MessageSender' -import { MessageReceiver } from '../MessageReceiver' +import { Symbols } from '../../symbols' +import { IndyWallet } from '../../wallet/IndyWallet' +import { Agent } from '../Agent' import { Dispatcher } from '../Dispatcher' import { EnvelopeService } from '../EnvelopeService' -import { getBaseConfig } from '../../__tests__/helpers' +import { MessageReceiver } from '../MessageReceiver' +import { MessageSender } from '../MessageSender' const config = getBaseConfig('Agent Class Test') diff --git a/src/agent/__tests__/AgentConfig.test.ts b/src/agent/__tests__/AgentConfig.test.ts index 99cef879e7..07109773f5 100644 --- a/src/agent/__tests__/AgentConfig.test.ts +++ b/src/agent/__tests__/AgentConfig.test.ts @@ -1,6 +1,6 @@ +import { getBaseConfig, getMockConnection } from '../../__tests__/helpers' import { DidCommService, DidDoc } from '../../modules/connections' import { AgentConfig } from '../AgentConfig' -import { getBaseConfig, getMockConnection } from '../../__tests__/helpers' describe('AgentConfig', () => { describe('getEndpoint', () => { diff --git a/src/agent/__tests__/MessageSender.test.ts b/src/agent/__tests__/MessageSender.test.ts index 0183a7e8b7..a1e58dda70 100644 --- a/src/agent/__tests__/MessageSender.test.ts +++ b/src/agent/__tests__/MessageSender.test.ts @@ -1,14 +1,13 @@ +import { getMockConnection, mockFunction } from '../../__tests__/helpers' import testLogger from '../../__tests__/logger' +import { ReturnRouteTypes } from '../../decorators/transport/TransportDecorator' +import { ConnectionRecord } from '../../modules/connections' +import { OutboundTransporter } from '../../transport' +import { AgentMessage } from '../AgentMessage' +import { EnvelopeService as EnvelopeServiceImpl } from '../EnvelopeService' import { MessageSender } from '../MessageSender' import { TransportSession, TransportService as TransportServiceImpl } from '../TransportService' -import { EnvelopeService as EnvelopeServiceImpl } from '../EnvelopeService' import { createOutboundMessage } from '../helpers' -import { AgentMessage } from '../AgentMessage' -import { OutboundTransporter } from '../../transport' -import { OutboundPackage } from '../../types' -import { ConnectionRecord } from '../../modules/connections' -import { ReturnRouteTypes } from '../../decorators/transport/TransportDecorator' -import { getMockConnection, mockFunction } from '../../__tests__/helpers' jest.mock('../TransportService') jest.mock('../EnvelopeService') @@ -19,11 +18,14 @@ class DummyOutboundTransporter implements OutboundTransporter { public start(): Promise { throw new Error('Method not implemented.') } + public stop(): Promise { throw new Error('Method not implemented.') } + public supportedSchemes: string[] = [] - public sendMessage(outboundPackage: OutboundPackage): Promise { + + public sendMessage() { return Promise.resolve() } } diff --git a/src/agent/__tests__/TransportService.test.ts b/src/agent/__tests__/TransportService.test.ts index 49249e87cf..541fb4fe87 100644 --- a/src/agent/__tests__/TransportService.test.ts +++ b/src/agent/__tests__/TransportService.test.ts @@ -1,7 +1,7 @@ +import { getMockConnection } from '../../__tests__/helpers' import testLogger from '../../__tests__/logger' import { ConnectionInvitationMessage, ConnectionRole, DidDoc, IndyAgentService } from '../../modules/connections' import { TransportService } from '../TransportService' -import { getMockConnection } from '../../__tests__/helpers' const logger = testLogger diff --git a/src/agent/helpers.ts b/src/agent/helpers.ts index f49098d0f7..21b04fa381 100644 --- a/src/agent/helpers.ts +++ b/src/agent/helpers.ts @@ -1,8 +1,8 @@ -import { ConnectionRecord } from '../modules/connections' -import { AgentMessage } from './AgentMessage' -import { OutboundMessage } from '../types' -import { ConnectionInvitationMessage } from '../modules/connections' import { AriesFrameworkError } from '../error' +import { ConnectionRecord, ConnectionInvitationMessage } from '../modules/connections' +import { OutboundMessage } from '../types' + +import { AgentMessage } from './AgentMessage' export function createOutboundMessage( connection: ConnectionRecord, diff --git a/src/agent/models/InboundMessageContext.ts b/src/agent/models/InboundMessageContext.ts index f89fde9c0a..7a4249a78e 100644 --- a/src/agent/models/InboundMessageContext.ts +++ b/src/agent/models/InboundMessageContext.ts @@ -1,6 +1,7 @@ import type { Verkey } from 'indy-sdk' -import { AgentMessage } from '../AgentMessage' + import { ConnectionRecord } from '../../modules/connections' +import { AgentMessage } from '../AgentMessage' export interface MessageContextParams { connection?: ConnectionRecord diff --git a/src/decorators/ack/AckDecorator.test.ts b/src/decorators/ack/AckDecorator.test.ts index c3e579a391..152b014c3a 100644 --- a/src/decorators/ack/AckDecorator.test.ts +++ b/src/decorators/ack/AckDecorator.test.ts @@ -1,7 +1,7 @@ +import { BaseMessage } from '../../agent/BaseMessage' import { JsonTransformer } from '../../utils/JsonTransformer' import { Compose } from '../../utils/mixins' -import { BaseMessage } from '../../agent/BaseMessage' import { AckDecorated } from './AckDecoratorExtension' describe('Decorators | AckDecoratorExtension', () => { diff --git a/src/decorators/ack/AckDecoratorExtension.ts b/src/decorators/ack/AckDecoratorExtension.ts index 0befc42833..025a262232 100644 --- a/src/decorators/ack/AckDecoratorExtension.ts +++ b/src/decorators/ack/AckDecoratorExtension.ts @@ -2,6 +2,7 @@ import { Expose, Type } from 'class-transformer' import { ValidateNested } from 'class-validator' import { BaseMessageConstructor } from '../../agent/BaseMessage' + import { AckDecorator } from './AckDecorator' export function AckDecorated(Base: T) { diff --git a/src/decorators/attachment/Attachment.test.ts b/src/decorators/attachment/Attachment.test.ts index 4715c396a3..8f21c58ccd 100644 --- a/src/decorators/attachment/Attachment.test.ts +++ b/src/decorators/attachment/Attachment.test.ts @@ -1,4 +1,5 @@ import { JsonTransformer } from '../..' + import { Attachment } from './Attachment' const mockJson = { diff --git a/src/decorators/attachment/Attachment.ts b/src/decorators/attachment/Attachment.ts index e95cfda777..d222260b9e 100644 --- a/src/decorators/attachment/Attachment.ts +++ b/src/decorators/attachment/Attachment.ts @@ -1,5 +1,6 @@ import { Expose, Type } from 'class-transformer' import { IsBase64, IsDate, IsHash, IsInt, IsMimeType, IsOptional, IsString, ValidateNested } from 'class-validator' + import { uuid } from '../../utils/uuid' export interface AttachmentOptions { diff --git a/src/decorators/attachment/AttachmentExtension.ts b/src/decorators/attachment/AttachmentExtension.ts index c7a98223db..adeaced14c 100644 --- a/src/decorators/attachment/AttachmentExtension.ts +++ b/src/decorators/attachment/AttachmentExtension.ts @@ -2,6 +2,7 @@ import { Expose, Type } from 'class-transformer' import { IsArray, IsOptional, ValidateNested } from 'class-validator' import { BaseMessageConstructor } from '../../agent/BaseMessage' + import { Attachment } from './Attachment' export function AttachmentDecorated(Base: T) { diff --git a/src/decorators/l10n/L10nDecoratorExtension.ts b/src/decorators/l10n/L10nDecoratorExtension.ts index de38d28401..9aff822a4f 100644 --- a/src/decorators/l10n/L10nDecoratorExtension.ts +++ b/src/decorators/l10n/L10nDecoratorExtension.ts @@ -2,6 +2,7 @@ import { Expose, Type } from 'class-transformer' import { ValidateNested } from 'class-validator' import { BaseMessageConstructor } from '../../agent/BaseMessage' + import { L10nDecorator } from './L10nDecorator' export function L10nDecorated(Base: T) { diff --git a/src/decorators/signature/SignatureDecoratorUtils.test.ts b/src/decorators/signature/SignatureDecoratorUtils.test.ts index 30acd345ec..7f5743c901 100644 --- a/src/decorators/signature/SignatureDecoratorUtils.test.ts +++ b/src/decorators/signature/SignatureDecoratorUtils.test.ts @@ -1,8 +1,9 @@ -import { signData, unpackAndVerifySignatureDecorator } from './SignatureDecoratorUtils' +import { getBaseConfig } from '../../__tests__/helpers' +import { AgentConfig } from '../../agent/AgentConfig' import { IndyWallet } from '../../wallet/IndyWallet' + import { SignatureDecorator } from './SignatureDecorator' -import { AgentConfig } from '../../agent/AgentConfig' -import { getBaseConfig } from '../../__tests__/helpers' +import { signData, unpackAndVerifySignatureDecorator } from './SignatureDecoratorUtils' jest.mock('../../utils/timestamp', () => { return { diff --git a/src/decorators/signature/SignatureDecoratorUtils.ts b/src/decorators/signature/SignatureDecoratorUtils.ts index c5b6b1d36d..d7932359e8 100644 --- a/src/decorators/signature/SignatureDecoratorUtils.ts +++ b/src/decorators/signature/SignatureDecoratorUtils.ts @@ -1,11 +1,13 @@ import type { Verkey } from 'indy-sdk' -import { SignatureDecorator } from './SignatureDecorator' + +import { AriesFrameworkError } from '../../error' +import { BufferEncoder } from '../../utils/BufferEncoder' +import { JsonEncoder } from '../../utils/JsonEncoder' +import { Buffer } from '../../utils/buffer' import timestamp from '../../utils/timestamp' import { Wallet } from '../../wallet/Wallet' -import { Buffer } from '../../utils/buffer' -import { JsonEncoder } from '../../utils/JsonEncoder' -import { BufferEncoder } from '../../utils/BufferEncoder' -import { AriesFrameworkError } from '../../error' + +import { SignatureDecorator } from './SignatureDecorator' /** * Unpack and verify signed data before casting it to the supplied type. diff --git a/src/decorators/thread/ThreadDecorator.test.ts b/src/decorators/thread/ThreadDecorator.test.ts index d633f1c043..18ef71ab6f 100644 --- a/src/decorators/thread/ThreadDecorator.test.ts +++ b/src/decorators/thread/ThreadDecorator.test.ts @@ -1,4 +1,5 @@ import { JsonTransformer } from '../../utils/JsonTransformer' + import { ThreadDecorator } from './ThreadDecorator' describe('Decorators | ThreadDecorator', () => { diff --git a/src/decorators/thread/ThreadDecorator.ts b/src/decorators/thread/ThreadDecorator.ts index 305732f24d..d9c3278c2a 100644 --- a/src/decorators/thread/ThreadDecorator.ts +++ b/src/decorators/thread/ThreadDecorator.ts @@ -1,5 +1,6 @@ import { Expose } from 'class-transformer' import { Matches } from 'class-validator' + import { MessageIdRegExp } from '../../agent/BaseMessage' /** diff --git a/src/decorators/thread/ThreadDecoratorExtension.ts b/src/decorators/thread/ThreadDecoratorExtension.ts index aea085deab..424ba7eb7d 100644 --- a/src/decorators/thread/ThreadDecoratorExtension.ts +++ b/src/decorators/thread/ThreadDecoratorExtension.ts @@ -2,6 +2,7 @@ import { Expose, Type } from 'class-transformer' import { ValidateNested } from 'class-validator' import { BaseMessageConstructor } from '../../agent/BaseMessage' + import { ThreadDecorator } from './ThreadDecorator' export function ThreadDecorated(Base: T) { diff --git a/src/decorators/timing/TimingDecorator.test.ts b/src/decorators/timing/TimingDecorator.test.ts index 84d31bcff7..321eb44579 100644 --- a/src/decorators/timing/TimingDecorator.test.ts +++ b/src/decorators/timing/TimingDecorator.test.ts @@ -1,4 +1,5 @@ import { JsonTransformer } from '../../utils/JsonTransformer' + import { TimingDecorator } from './TimingDecorator' describe('Decorators | TimingDecorator', () => { diff --git a/src/decorators/timing/TimingDecoratorExtension.ts b/src/decorators/timing/TimingDecoratorExtension.ts index 88f6580a5e..19fe6300c0 100644 --- a/src/decorators/timing/TimingDecoratorExtension.ts +++ b/src/decorators/timing/TimingDecoratorExtension.ts @@ -2,6 +2,7 @@ import { Expose, Type } from 'class-transformer' import { ValidateNested } from 'class-validator' import { BaseMessageConstructor } from '../../agent/BaseMessage' + import { TimingDecorator } from './TimingDecorator' export function TimingDecorated(Base: T) { diff --git a/src/decorators/transport/TransportDecorator.test.ts b/src/decorators/transport/TransportDecorator.test.ts index 92afde9ea4..4843a9ea1e 100644 --- a/src/decorators/transport/TransportDecorator.test.ts +++ b/src/decorators/transport/TransportDecorator.test.ts @@ -1,7 +1,9 @@ -import { TransportDecorator, ReturnRouteTypes } from './TransportDecorator' import { validateOrReject } from 'class-validator' + import { JsonTransformer } from '../../utils/JsonTransformer' +import { TransportDecorator, ReturnRouteTypes } from './TransportDecorator' + const validTranport = (obj: Record) => validateOrReject(JsonTransformer.fromJSON(obj, TransportDecorator)) const expectValid = (obj: Record) => expect(validTranport(obj)).resolves.toBeUndefined() diff --git a/src/decorators/transport/TransportDecoratorExtension.ts b/src/decorators/transport/TransportDecoratorExtension.ts index b6e0c4abfc..0b2c7c04c7 100644 --- a/src/decorators/transport/TransportDecoratorExtension.ts +++ b/src/decorators/transport/TransportDecoratorExtension.ts @@ -1,8 +1,10 @@ import { Expose, Type } from 'class-transformer' import { ValidateNested } from 'class-validator' -import { TransportDecorator, ReturnRouteTypes } from './TransportDecorator' + import { BaseMessageConstructor } from '../../agent/BaseMessage' +import { TransportDecorator, ReturnRouteTypes } from './TransportDecorator' + export function TransportDecorated(Base: T) { class TransportDecoratorExtension extends Base { @Expose({ name: '~transport' }) diff --git a/src/logger/BaseLogger.ts b/src/logger/BaseLogger.ts index decefa6681..baa524520b 100644 --- a/src/logger/BaseLogger.ts +++ b/src/logger/BaseLogger.ts @@ -11,6 +11,7 @@ export abstract class BaseLogger implements Logger { return logLevel >= this.logLevel } + /* eslint-disable @typescript-eslint/no-explicit-any */ public abstract test(message: string, data?: Record): void public abstract trace(message: string, data?: Record): void public abstract debug(message: string, data?: Record): void @@ -18,4 +19,5 @@ export abstract class BaseLogger implements Logger { public abstract warn(message: string, data?: Record): void public abstract error(message: string, data?: Record): void public abstract fatal(message: string, data?: Record): void + /* eslint-enable @typescript-eslint/no-explicit-any */ } diff --git a/src/modules/basic-messages/BasicMessageEvents.ts b/src/modules/basic-messages/BasicMessageEvents.ts index 79a450a2b1..616b1d3102 100644 --- a/src/modules/basic-messages/BasicMessageEvents.ts +++ b/src/modules/basic-messages/BasicMessageEvents.ts @@ -1,5 +1,7 @@ import type { Verkey } from 'indy-sdk' + import { BaseEvent } from '../../agent/Events' + import { BasicMessage } from './messages' export enum BasicMessageEventTypes { diff --git a/src/modules/basic-messages/BasicMessagesModule.ts b/src/modules/basic-messages/BasicMessagesModule.ts index 2d8a47e86b..3aafd2eb36 100644 --- a/src/modules/basic-messages/BasicMessagesModule.ts +++ b/src/modules/basic-messages/BasicMessagesModule.ts @@ -1,11 +1,12 @@ import type { WalletQuery } from 'indy-sdk' import { Lifecycle, scoped } from 'tsyringe' -import { BasicMessageService } from './services' +import { Dispatcher } from '../../agent/Dispatcher' import { MessageSender } from '../../agent/MessageSender' import { ConnectionRecord } from '../connections' -import { Dispatcher } from '../../agent/Dispatcher' + import { BasicMessageHandler } from './handlers' +import { BasicMessageService } from './services' @scoped(Lifecycle.ContainerScoped) export class BasicMessagesModule { diff --git a/src/modules/basic-messages/__tests__/BasicMessageService.test.ts b/src/modules/basic-messages/__tests__/BasicMessageService.test.ts index 478a0d580b..2432171d00 100644 --- a/src/modules/basic-messages/__tests__/BasicMessageService.test.ts +++ b/src/modules/basic-messages/__tests__/BasicMessageService.test.ts @@ -1,17 +1,17 @@ -import { IndyWallet } from '../../../wallet/IndyWallet' -import { Wallet } from '../../../wallet/Wallet' +import { getBaseConfig } from '../../../__tests__/helpers' +import { AgentConfig } from '../../../agent/AgentConfig' +import { EventEmitter } from '../../../agent/EventEmitter' +import { InboundMessageContext } from '../../../agent/models/InboundMessageContext' +import { IndyStorageService } from '../../../storage/IndyStorageService' import { Repository } from '../../../storage/Repository' import { StorageService } from '../../../storage/StorageService' -import { IndyStorageService } from '../../../storage/IndyStorageService' -import { BasicMessageService } from '../services' -import { BasicMessageRecord } from '../repository/BasicMessageRecord' -import { BasicMessage } from '../messages' -import { InboundMessageContext } from '../../../agent/models/InboundMessageContext' +import { IndyWallet } from '../../../wallet/IndyWallet' +import { Wallet } from '../../../wallet/Wallet' import { ConnectionRecord } from '../../connections' -import { AgentConfig } from '../../../agent/AgentConfig' -import { getBaseConfig } from '../../../__tests__/helpers' -import { EventEmitter } from '../../../agent/EventEmitter' import { BasicMessageEventTypes, BasicMessageReceivedEvent } from '../BasicMessageEvents' +import { BasicMessage } from '../messages' +import { BasicMessageRecord } from '../repository/BasicMessageRecord' +import { BasicMessageService } from '../services' describe('BasicMessageService', () => { const mockConnectionRecord = { diff --git a/src/modules/basic-messages/handlers/BasicMessageHandler.ts b/src/modules/basic-messages/handlers/BasicMessageHandler.ts index 4af8f6a198..597de3fb69 100644 --- a/src/modules/basic-messages/handlers/BasicMessageHandler.ts +++ b/src/modules/basic-messages/handlers/BasicMessageHandler.ts @@ -1,7 +1,7 @@ import { Handler, HandlerInboundMessage } from '../../../agent/Handler' -import { BasicMessageService } from '../services/BasicMessageService' -import { BasicMessage } from '../messages' import { AriesFrameworkError } from '../../../error' +import { BasicMessage } from '../messages' +import { BasicMessageService } from '../services/BasicMessageService' export class BasicMessageHandler implements Handler { private basicMessageService: BasicMessageService diff --git a/src/modules/basic-messages/messages/BasicMessage.ts b/src/modules/basic-messages/messages/BasicMessage.ts index bf3641bc11..e845aa980b 100644 --- a/src/modules/basic-messages/messages/BasicMessage.ts +++ b/src/modules/basic-messages/messages/BasicMessage.ts @@ -1,7 +1,8 @@ -import { Equals, IsDate, IsString } from 'class-validator' import { Expose, Type } from 'class-transformer' +import { Equals, IsDate, IsString } from 'class-validator' import { AgentMessage } from '../../../agent/AgentMessage' + import { MessageType } from './BasicMessageMessageType' export class BasicMessage extends AgentMessage { diff --git a/src/modules/basic-messages/repository/BasicMessageRecord.ts b/src/modules/basic-messages/repository/BasicMessageRecord.ts index 06f050c4a9..14e27ef751 100644 --- a/src/modules/basic-messages/repository/BasicMessageRecord.ts +++ b/src/modules/basic-messages/repository/BasicMessageRecord.ts @@ -1,5 +1,5 @@ -import { uuid } from '../../../utils/uuid' import { BaseRecord, Tags } from '../../../storage/BaseRecord' +import { uuid } from '../../../utils/uuid' export interface BasicMessageStorageProps { id?: string diff --git a/src/modules/basic-messages/repository/BasicMessageRepository.ts b/src/modules/basic-messages/repository/BasicMessageRepository.ts index 164ef19700..c0cb43386b 100644 --- a/src/modules/basic-messages/repository/BasicMessageRepository.ts +++ b/src/modules/basic-messages/repository/BasicMessageRepository.ts @@ -1,10 +1,11 @@ import { inject, scoped, Lifecycle } from 'tsyringe' import { Repository } from '../../../storage/Repository' -import { BasicMessageRecord } from './BasicMessageRecord' import { StorageService } from '../../../storage/StorageService' import { Symbols } from '../../../symbols' +import { BasicMessageRecord } from './BasicMessageRecord' + @scoped(Lifecycle.ContainerScoped) export class BasicMessageRepository extends Repository { public constructor(@inject(Symbols.StorageService) storageService: StorageService) { diff --git a/src/modules/basic-messages/services/BasicMessageService.ts b/src/modules/basic-messages/services/BasicMessageService.ts index 883d204187..8364835b6b 100644 --- a/src/modules/basic-messages/services/BasicMessageService.ts +++ b/src/modules/basic-messages/services/BasicMessageService.ts @@ -1,15 +1,15 @@ import type { WalletQuery } from 'indy-sdk' import { Lifecycle, scoped } from 'tsyringe' -import { OutboundMessage } from '../../../types' +import { EventEmitter } from '../../../agent/EventEmitter' import { createOutboundMessage } from '../../../agent/helpers' -import { BasicMessageRecord } from '../repository/BasicMessageRecord' -import { ConnectionRecord } from '../../connections/repository/ConnectionRecord' import { InboundMessageContext } from '../../../agent/models/InboundMessageContext' +import { OutboundMessage } from '../../../types' +import { ConnectionRecord } from '../../connections/repository/ConnectionRecord' +import { BasicMessageEventTypes, BasicMessageReceivedEvent } from '../BasicMessageEvents' import { BasicMessage } from '../messages' import { BasicMessageRepository } from '../repository' -import { EventEmitter } from '../../../agent/EventEmitter' -import { BasicMessageEventTypes, BasicMessageReceivedEvent } from '../BasicMessageEvents' +import { BasicMessageRecord } from '../repository/BasicMessageRecord' @scoped(Lifecycle.ContainerScoped) export class BasicMessageService { diff --git a/src/modules/common/messages/AckMessage.ts b/src/modules/common/messages/AckMessage.ts index 10f4991387..0ec63e327d 100644 --- a/src/modules/common/messages/AckMessage.ts +++ b/src/modules/common/messages/AckMessage.ts @@ -1,6 +1,7 @@ import { Equals, IsEnum } from 'class-validator' import { AgentMessage } from '../../../agent/AgentMessage' + import { CommonMessageType } from './CommonMessageType' /** diff --git a/src/modules/connections/ConnectionEvents.ts b/src/modules/connections/ConnectionEvents.ts index e4cef97cd6..0cac15b837 100644 --- a/src/modules/connections/ConnectionEvents.ts +++ b/src/modules/connections/ConnectionEvents.ts @@ -1,6 +1,7 @@ import { BaseEvent } from '../../agent/Events' -import { ConnectionRecord } from './repository/ConnectionRecord' + import { ConnectionState } from './models/ConnectionState' +import { ConnectionRecord } from './repository/ConnectionRecord' export enum ConnectionEventTypes { ConnectionStateChanged = 'ConnectionStateChanged', diff --git a/src/modules/connections/ConnectionsModule.ts b/src/modules/connections/ConnectionsModule.ts index afe7af69ef..95f6d4828e 100644 --- a/src/modules/connections/ConnectionsModule.ts +++ b/src/modules/connections/ConnectionsModule.ts @@ -2,13 +2,11 @@ import type { Verkey } from 'indy-sdk' import { Lifecycle, scoped } from 'tsyringe' import { AgentConfig } from '../../agent/AgentConfig' +import { Dispatcher } from '../../agent/Dispatcher' import { MessageSender } from '../../agent/MessageSender' import { createOutboundMessage } from '../../agent/helpers' -import { Dispatcher } from '../../agent/Dispatcher' -import { ConnectionService, TrustPingService } from './services' import { ConsumerRoutingService } from '../routing' -import { ConnectionRecord } from './repository/ConnectionRecord' -import { ConnectionInvitationMessage } from './messages' + import { ConnectionRequestHandler, ConnectionResponseHandler, @@ -16,6 +14,9 @@ import { TrustPingMessageHandler, TrustPingResponseMessageHandler, } from './handlers' +import { ConnectionInvitationMessage } from './messages' +import { ConnectionRecord } from './repository/ConnectionRecord' +import { ConnectionService, TrustPingService } from './services' @scoped(Lifecycle.ContainerScoped) export class ConnectionsModule { diff --git a/src/modules/connections/__tests__/ConnectionInvitationMessage.test.ts b/src/modules/connections/__tests__/ConnectionInvitationMessage.test.ts index 317780a65c..9a24b54069 100644 --- a/src/modules/connections/__tests__/ConnectionInvitationMessage.test.ts +++ b/src/modules/connections/__tests__/ConnectionInvitationMessage.test.ts @@ -1,7 +1,7 @@ import { validateOrReject } from 'class-validator' -import { ConnectionInvitationMessage } from '../messages/ConnectionInvitationMessage' import { JsonTransformer } from '../../../utils/JsonTransformer' +import { ConnectionInvitationMessage } from '../messages/ConnectionInvitationMessage' describe('ConnectionInvitationMessage', () => { it('should allow routingKeys to be left out of inline invitation', async () => { diff --git a/src/modules/connections/__tests__/ConnectionService.test.ts b/src/modules/connections/__tests__/ConnectionService.test.ts index f2ed5b171a..cca9571e25 100644 --- a/src/modules/connections/__tests__/ConnectionService.test.ts +++ b/src/modules/connections/__tests__/ConnectionService.test.ts @@ -1,24 +1,24 @@ +import { getBaseConfig, getMockConnection, mockFunction } from '../../../__tests__/helpers' +import { AgentConfig } from '../../../agent/AgentConfig' +import { EventEmitter } from '../../../agent/EventEmitter' +import { InboundMessageContext } from '../../../agent/models/InboundMessageContext' +import { SignatureDecorator } from '../../../decorators/signature/SignatureDecorator' +import { signData, unpackAndVerifySignatureDecorator } from '../../../decorators/signature/SignatureDecoratorUtils' +import { JsonTransformer } from '../../../utils/JsonTransformer' import { uuid } from '../../../utils/uuid' import { IndyWallet } from '../../../wallet/IndyWallet' import { Wallet } from '../../../wallet/Wallet' -import { ConnectionService } from '../services/ConnectionService' -import { ConnectionRecord } from '../repository/ConnectionRecord' -import { AgentConfig } from '../../../agent/AgentConfig' -import { Connection, ConnectionState, ConnectionRole, DidDoc, DidCommService } from '../models' +import { AckMessage, AckStatus } from '../../common' import { ConnectionInvitationMessage, ConnectionRequestMessage, ConnectionResponseMessage, TrustPingMessage, } from '../messages' -import { AckMessage, AckStatus } from '../../common' -import { signData, unpackAndVerifySignatureDecorator } from '../../../decorators/signature/SignatureDecoratorUtils' -import { InboundMessageContext } from '../../../agent/models/InboundMessageContext' -import { SignatureDecorator } from '../../../decorators/signature/SignatureDecorator' -import { JsonTransformer } from '../../../utils/JsonTransformer' -import { EventEmitter } from '../../../agent/EventEmitter' -import { getBaseConfig, getMockConnection, mockFunction } from '../../../__tests__/helpers' +import { Connection, ConnectionState, ConnectionRole, DidDoc, DidCommService } from '../models' +import { ConnectionRecord } from '../repository/ConnectionRecord' import { ConnectionRepository } from '../repository/ConnectionRepository' +import { ConnectionService } from '../services/ConnectionService' jest.mock('../repository/ConnectionRepository') const ConnectionRepositoryMock = ConnectionRepository as jest.Mock @@ -367,6 +367,9 @@ describe('ConnectionService', () => { verkey, state: ConnectionState.Requested, role: ConnectionRole.Inviter, + tags: { + threadId: 'test', + }, }) mockFunction(connectionRepository.getById).mockReturnValue(Promise.resolve(mockConnection)) diff --git a/src/modules/connections/handlers/AckMessageHandler.ts b/src/modules/connections/handlers/AckMessageHandler.ts index 406a35be9e..7b3ae9cbfc 100644 --- a/src/modules/connections/handlers/AckMessageHandler.ts +++ b/src/modules/connections/handlers/AckMessageHandler.ts @@ -1,6 +1,6 @@ import { Handler, HandlerInboundMessage } from '../../../agent/Handler' -import { ConnectionService } from '../services/ConnectionService' import { AckMessage } from '../../common' +import { ConnectionService } from '../services/ConnectionService' export class AckMessageHandler implements Handler { private connectionService: ConnectionService diff --git a/src/modules/connections/handlers/ConnectionRequestHandler.ts b/src/modules/connections/handlers/ConnectionRequestHandler.ts index 99b3ae4407..7202bb5241 100644 --- a/src/modules/connections/handlers/ConnectionRequestHandler.ts +++ b/src/modules/connections/handlers/ConnectionRequestHandler.ts @@ -1,9 +1,9 @@ -import { Handler, HandlerInboundMessage } from '../../../agent/Handler' -import { ConnectionService } from '../services/ConnectionService' -import { ConnectionRequestMessage } from '../messages' import { AgentConfig } from '../../../agent/AgentConfig' +import { Handler, HandlerInboundMessage } from '../../../agent/Handler' import { createOutboundMessage } from '../../../agent/helpers' import { AriesFrameworkError } from '../../../error' +import { ConnectionRequestMessage } from '../messages' +import { ConnectionService } from '../services/ConnectionService' export class ConnectionRequestHandler implements Handler { private connectionService: ConnectionService diff --git a/src/modules/connections/handlers/ConnectionResponseHandler.ts b/src/modules/connections/handlers/ConnectionResponseHandler.ts index 8997686692..785b6a7c46 100644 --- a/src/modules/connections/handlers/ConnectionResponseHandler.ts +++ b/src/modules/connections/handlers/ConnectionResponseHandler.ts @@ -1,9 +1,9 @@ -import { Handler, HandlerInboundMessage } from '../../../agent/Handler' import { AgentConfig } from '../../../agent/AgentConfig' +import { Handler, HandlerInboundMessage } from '../../../agent/Handler' import { createOutboundMessage } from '../../../agent/helpers' -import { ConnectionService } from '../services/ConnectionService' -import { ConnectionResponseMessage } from '../messages' import { AriesFrameworkError } from '../../../error' +import { ConnectionResponseMessage } from '../messages' +import { ConnectionService } from '../services/ConnectionService' export class ConnectionResponseHandler implements Handler { private connectionService: ConnectionService diff --git a/src/modules/connections/handlers/TrustPingMessageHandler.ts b/src/modules/connections/handlers/TrustPingMessageHandler.ts index 9f7552cb30..36ece3e7f2 100644 --- a/src/modules/connections/handlers/TrustPingMessageHandler.ts +++ b/src/modules/connections/handlers/TrustPingMessageHandler.ts @@ -1,9 +1,9 @@ import { Handler, HandlerInboundMessage } from '../../../agent/Handler' -import { TrustPingService } from '../services/TrustPingService' -import { ConnectionService } from '../services/ConnectionService' -import { ConnectionState } from '../models' -import { TrustPingMessage } from '../messages' import { AriesFrameworkError } from '../../../error' +import { TrustPingMessage } from '../messages' +import { ConnectionState } from '../models' +import { ConnectionService } from '../services/ConnectionService' +import { TrustPingService } from '../services/TrustPingService' export class TrustPingMessageHandler implements Handler { private trustPingService: TrustPingService diff --git a/src/modules/connections/handlers/TrustPingResponseMessageHandler.ts b/src/modules/connections/handlers/TrustPingResponseMessageHandler.ts index 10e0c87034..9165398cbe 100644 --- a/src/modules/connections/handlers/TrustPingResponseMessageHandler.ts +++ b/src/modules/connections/handlers/TrustPingResponseMessageHandler.ts @@ -1,6 +1,6 @@ import { Handler, HandlerInboundMessage } from '../../../agent/Handler' -import { TrustPingService } from '../services/TrustPingService' import { TrustPingResponseMessage } from '../messages' +import { TrustPingService } from '../services/TrustPingService' export class TrustPingResponseMessageHandler implements Handler { private trustPingService: TrustPingService diff --git a/src/modules/connections/messages/ConnectionInvitationMessage.ts b/src/modules/connections/messages/ConnectionInvitationMessage.ts index 69c74dd5ff..529662ed4c 100644 --- a/src/modules/connections/messages/ConnectionInvitationMessage.ts +++ b/src/modules/connections/messages/ConnectionInvitationMessage.ts @@ -5,6 +5,7 @@ import { AgentMessage } from '../../../agent/AgentMessage' import { AriesFrameworkError } from '../../../error' import { decodeInvitationFromUrl, encodeInvitationToUrl } from '../../../helpers' import { replaceLegacyDidSovPrefix } from '../../../utils/messageType' + import { ConnectionMessageType } from './ConnectionMessageType' // TODO: improve typing of `DIDInvitationData` and `InlineInvitationData` so properties can't be mixed diff --git a/src/modules/connections/messages/ConnectionRequestMessage.ts b/src/modules/connections/messages/ConnectionRequestMessage.ts index 48e4779883..4351ed5e10 100644 --- a/src/modules/connections/messages/ConnectionRequestMessage.ts +++ b/src/modules/connections/messages/ConnectionRequestMessage.ts @@ -2,9 +2,10 @@ import { Type } from 'class-transformer' import { Equals, IsString, ValidateNested } from 'class-validator' import { AgentMessage } from '../../../agent/AgentMessage' -import { ConnectionMessageType } from './ConnectionMessageType' import { Connection, DidDoc } from '../models' +import { ConnectionMessageType } from './ConnectionMessageType' + export interface ConnectionRequestMessageOptions { id?: string label: string diff --git a/src/modules/connections/messages/ConnectionResponseMessage.ts b/src/modules/connections/messages/ConnectionResponseMessage.ts index 34673dc67a..b1d557101e 100644 --- a/src/modules/connections/messages/ConnectionResponseMessage.ts +++ b/src/modules/connections/messages/ConnectionResponseMessage.ts @@ -1,10 +1,11 @@ -import { Equals, ValidateNested } from 'class-validator' import { Type, Expose } from 'class-transformer' +import { Equals, ValidateNested } from 'class-validator' import { AgentMessage } from '../../../agent/AgentMessage' -import { ConnectionMessageType } from './ConnectionMessageType' import { SignatureDecorator } from '../../../decorators/signature/SignatureDecorator' +import { ConnectionMessageType } from './ConnectionMessageType' + export interface ConnectionResponseMessageOptions { id?: string threadId: string diff --git a/src/modules/connections/messages/TrustPingMessage.ts b/src/modules/connections/messages/TrustPingMessage.ts index d0332ad792..8da2749a3f 100644 --- a/src/modules/connections/messages/TrustPingMessage.ts +++ b/src/modules/connections/messages/TrustPingMessage.ts @@ -1,10 +1,11 @@ -import { Equals, IsString, IsBoolean } from 'class-validator' import { Expose } from 'class-transformer' +import { Equals, IsString, IsBoolean } from 'class-validator' import { AgentMessage } from '../../../agent/AgentMessage' -import { ConnectionMessageType } from './ConnectionMessageType' import { TimingDecorator } from '../../../decorators/timing/TimingDecorator' +import { ConnectionMessageType } from './ConnectionMessageType' + export interface TrustPingMessageOptions { comment?: string id?: string diff --git a/src/modules/connections/messages/TrustPingResponseMessage.ts b/src/modules/connections/messages/TrustPingResponseMessage.ts index 39e19e9a59..cbe23b25c9 100644 --- a/src/modules/connections/messages/TrustPingResponseMessage.ts +++ b/src/modules/connections/messages/TrustPingResponseMessage.ts @@ -1,9 +1,10 @@ import { Equals, IsString } from 'class-validator' import { AgentMessage } from '../../../agent/AgentMessage' -import { ConnectionMessageType } from './ConnectionMessageType' import { TimingDecorator } from '../../../decorators/timing/TimingDecorator' +import { ConnectionMessageType } from './ConnectionMessageType' + export interface TrustPingResponseMessageOptions { comment?: string id?: string diff --git a/src/modules/connections/models/Connection.ts b/src/modules/connections/models/Connection.ts index f5a087785d..e533a695b0 100644 --- a/src/modules/connections/models/Connection.ts +++ b/src/modules/connections/models/Connection.ts @@ -1,5 +1,5 @@ -import { IsString, ValidateNested } from 'class-validator' import { Expose, Type } from 'class-transformer' +import { IsString, ValidateNested } from 'class-validator' import { DidDoc } from './did/DidDoc' diff --git a/src/modules/connections/models/did/__tests__/Authentication.test.ts b/src/modules/connections/models/did/__tests__/Authentication.test.ts index f81d5bc17f..d9f8a1065c 100644 --- a/src/modules/connections/models/did/__tests__/Authentication.test.ts +++ b/src/modules/connections/models/did/__tests__/Authentication.test.ts @@ -1,4 +1,5 @@ import { classToPlain, plainToClass } from 'class-transformer' + import { Authentication, AuthenticationTransformer, diff --git a/src/modules/connections/models/did/__tests__/DidDoc.test.ts b/src/modules/connections/models/did/__tests__/DidDoc.test.ts index f0b8ba47f3..a1b7898a61 100644 --- a/src/modules/connections/models/did/__tests__/DidDoc.test.ts +++ b/src/modules/connections/models/did/__tests__/DidDoc.test.ts @@ -1,7 +1,7 @@ import { classToPlain, plainToClass } from 'class-transformer' -import { ReferencedAuthentication, EmbeddedAuthentication } from '../authentication' import { DidDoc } from '../DidDoc' +import { ReferencedAuthentication, EmbeddedAuthentication } from '../authentication' import { Ed25119Sig2018, EddsaSaSigSecp256k1, RsaSig2018 } from '../publicKey' import { Service, IndyAgentService, DidCommService } from '../service' diff --git a/src/modules/connections/models/did/__tests__/PublicKey.test.ts b/src/modules/connections/models/did/__tests__/PublicKey.test.ts index fb799e0073..ee0c488cd4 100644 --- a/src/modules/connections/models/did/__tests__/PublicKey.test.ts +++ b/src/modules/connections/models/did/__tests__/PublicKey.test.ts @@ -1,4 +1,5 @@ import { ClassConstructor, classToPlain, plainToClass } from 'class-transformer' + import { PublicKeyTransformer, PublicKey, @@ -83,6 +84,7 @@ describe('Did | PublicKey', () => { ) const publicKeyClassToJsonTests: [string, PublicKey, Record, string][] = + // eslint-disable-next-line @typescript-eslint/no-explicit-any publicKeysJson.map((pk) => [pk.class.name, new pk.class({ ...(pk.json as any) }), pk.json, pk.valueKey]) test.each(publicKeyClassToJsonTests)( diff --git a/src/modules/connections/models/did/__tests__/Service.test.ts b/src/modules/connections/models/did/__tests__/Service.test.ts index 6bb701de36..f9bb29822c 100644 --- a/src/modules/connections/models/did/__tests__/Service.test.ts +++ b/src/modules/connections/models/did/__tests__/Service.test.ts @@ -1,4 +1,5 @@ import { classToPlain, plainToClass } from 'class-transformer' + import { Service, ServiceTransformer, serviceTypes, IndyAgentService, DidCommService } from '../service' describe('Did | Service', () => { diff --git a/src/modules/connections/models/did/authentication/EmbeddedAuthentication.ts b/src/modules/connections/models/did/authentication/EmbeddedAuthentication.ts index 5b90d9c5e2..bb4cd5a692 100644 --- a/src/modules/connections/models/did/authentication/EmbeddedAuthentication.ts +++ b/src/modules/connections/models/did/authentication/EmbeddedAuthentication.ts @@ -1,5 +1,7 @@ import { IsNotEmpty, ValidateNested } from 'class-validator' + import { PublicKey } from '../publicKey/PublicKey' + import { Authentication } from './Authentication' export class EmbeddedAuthentication extends Authentication { diff --git a/src/modules/connections/models/did/authentication/ReferencedAuthentication.ts b/src/modules/connections/models/did/authentication/ReferencedAuthentication.ts index 0c4c5ecb23..a4ee64aea8 100644 --- a/src/modules/connections/models/did/authentication/ReferencedAuthentication.ts +++ b/src/modules/connections/models/did/authentication/ReferencedAuthentication.ts @@ -1,6 +1,8 @@ import { Transform } from 'class-transformer' import { IsString } from 'class-validator' + import { PublicKey } from '../publicKey/PublicKey' + import { Authentication } from './Authentication' export class ReferencedAuthentication extends Authentication { diff --git a/src/modules/connections/models/did/authentication/index.ts b/src/modules/connections/models/did/authentication/index.ts index 92cfe5a274..58d171da8a 100644 --- a/src/modules/connections/models/did/authentication/index.ts +++ b/src/modules/connections/models/did/authentication/index.ts @@ -1,7 +1,8 @@ import { Transform, TransformationType, ClassConstructor, plainToClass, classToPlain } from 'class-transformer' -import { AriesFrameworkError } from '../../../../../error' +import { AriesFrameworkError } from '../../../../../error' import { PublicKey, publicKeyTypes } from '../publicKey' + import { Authentication } from './Authentication' import { EmbeddedAuthentication } from './EmbeddedAuthentication' import { ReferencedAuthentication } from './ReferencedAuthentication' diff --git a/src/modules/connections/models/did/publicKey/Ed25119Sig2018.ts b/src/modules/connections/models/did/publicKey/Ed25119Sig2018.ts index 99e994e9d6..7077a5ac25 100644 --- a/src/modules/connections/models/did/publicKey/Ed25119Sig2018.ts +++ b/src/modules/connections/models/did/publicKey/Ed25119Sig2018.ts @@ -1,5 +1,6 @@ import { Expose } from 'class-transformer' import { Equals, IsString } from 'class-validator' + import { PublicKey } from './PublicKey' export class Ed25119Sig2018 extends PublicKey { diff --git a/src/modules/connections/models/did/publicKey/EddsaSaSigSecp256k1.ts b/src/modules/connections/models/did/publicKey/EddsaSaSigSecp256k1.ts index 673416662c..f9c2eee646 100644 --- a/src/modules/connections/models/did/publicKey/EddsaSaSigSecp256k1.ts +++ b/src/modules/connections/models/did/publicKey/EddsaSaSigSecp256k1.ts @@ -1,5 +1,6 @@ import { Expose } from 'class-transformer' import { Equals, IsString } from 'class-validator' + import { PublicKey } from './PublicKey' export class EddsaSaSigSecp256k1 extends PublicKey { diff --git a/src/modules/connections/models/did/publicKey/RsaSig2018.ts b/src/modules/connections/models/did/publicKey/RsaSig2018.ts index 79f2371d53..fdc106b443 100644 --- a/src/modules/connections/models/did/publicKey/RsaSig2018.ts +++ b/src/modules/connections/models/did/publicKey/RsaSig2018.ts @@ -1,5 +1,6 @@ import { Expose } from 'class-transformer' import { Equals, IsString } from 'class-validator' + import { PublicKey } from './PublicKey' export class RsaSig2018 extends PublicKey { diff --git a/src/modules/connections/models/did/publicKey/index.ts b/src/modules/connections/models/did/publicKey/index.ts index 9418a0337e..d40455b884 100644 --- a/src/modules/connections/models/did/publicKey/index.ts +++ b/src/modules/connections/models/did/publicKey/index.ts @@ -1,8 +1,8 @@ import { Transform, ClassConstructor, plainToClass } from 'class-transformer' -import { PublicKey } from './PublicKey' import { Ed25119Sig2018 } from './Ed25119Sig2018' import { EddsaSaSigSecp256k1 } from './EddsaSaSigSecp256k1' +import { PublicKey } from './PublicKey' import { RsaSig2018 } from './RsaSig2018' export const publicKeyTypes: { [key: string]: unknown | undefined } = { diff --git a/src/modules/connections/models/did/service/DidCommService.ts b/src/modules/connections/models/did/service/DidCommService.ts index 1498e73e57..9f9ffe91a3 100644 --- a/src/modules/connections/models/did/service/DidCommService.ts +++ b/src/modules/connections/models/did/service/DidCommService.ts @@ -1,4 +1,5 @@ import { ArrayNotEmpty, IsOptional, IsString } from 'class-validator' + import { Service } from './Service' export class DidCommService extends Service { diff --git a/src/modules/connections/models/did/service/IndyAgentService.ts b/src/modules/connections/models/did/service/IndyAgentService.ts index 9a96422f76..fd380af430 100644 --- a/src/modules/connections/models/did/service/IndyAgentService.ts +++ b/src/modules/connections/models/did/service/IndyAgentService.ts @@ -1,4 +1,5 @@ import { ArrayNotEmpty, IsOptional, IsString } from 'class-validator' + import { Service } from './Service' export class IndyAgentService extends Service { diff --git a/src/modules/connections/models/did/service/index.ts b/src/modules/connections/models/did/service/index.ts index 2b1b92886e..6c525a2e6c 100644 --- a/src/modules/connections/models/did/service/index.ts +++ b/src/modules/connections/models/did/service/index.ts @@ -1,7 +1,7 @@ import { Transform, ClassConstructor, plainToClass } from 'class-transformer' -import { IndyAgentService } from './IndyAgentService' import { DidCommService } from './DidCommService' +import { IndyAgentService } from './IndyAgentService' import { Service } from './Service' export const serviceTypes: { [key: string]: unknown | undefined } = { diff --git a/src/modules/connections/repository/ConnectionRecord.ts b/src/modules/connections/repository/ConnectionRecord.ts index e51369535d..f0d3d3b0db 100644 --- a/src/modules/connections/repository/ConnectionRecord.ts +++ b/src/modules/connections/repository/ConnectionRecord.ts @@ -1,12 +1,13 @@ import { Type } from 'class-transformer' -import { uuid } from '../../../utils/uuid' -import { BaseRecord, Tags } from '../../../storage/BaseRecord' -import { ConnectionState } from '..' -import { ConnectionInvitationMessage } from '..' -import { ConnectionRole } from '..' -import { DidDoc } from '..' import type { Did, Verkey } from 'indy-sdk' + import { AriesFrameworkError } from '../../../error' +import { BaseRecord, Tags } from '../../../storage/BaseRecord' +import { uuid } from '../../../utils/uuid' +import { ConnectionInvitationMessage } from '../messages/ConnectionInvitationMessage' +import { ConnectionRole } from '../models/ConnectionRole' +import { ConnectionState } from '../models/ConnectionState' +import { DidDoc } from '../models/did/DidDoc' interface ConnectionProps { id?: string diff --git a/src/modules/connections/repository/ConnectionRepository.ts b/src/modules/connections/repository/ConnectionRepository.ts index ed7fde3551..d5e6902cde 100644 --- a/src/modules/connections/repository/ConnectionRepository.ts +++ b/src/modules/connections/repository/ConnectionRepository.ts @@ -1,10 +1,11 @@ import { inject, scoped, Lifecycle } from 'tsyringe' import { Repository } from '../../../storage/Repository' -import { ConnectionRecord } from './ConnectionRecord' import { StorageService } from '../../../storage/StorageService' import { Symbols } from '../../../symbols' +import { ConnectionRecord } from './ConnectionRecord' + @scoped(Lifecycle.ContainerScoped) export class ConnectionRepository extends Repository { public constructor(@inject(Symbols.StorageService) storageService: StorageService) { diff --git a/src/modules/connections/services/ConnectionService.ts b/src/modules/connections/services/ConnectionService.ts index 4e14160d31..f3e1c5d512 100644 --- a/src/modules/connections/services/ConnectionService.ts +++ b/src/modules/connections/services/ConnectionService.ts @@ -1,19 +1,24 @@ -import { Verkey } from 'indy-sdk' import { validateOrReject } from 'class-validator' +import { Verkey } from 'indy-sdk' import { inject, scoped, Lifecycle } from 'tsyringe' import { AgentConfig } from '../../../agent/AgentConfig' -import { ConnectionRecord, ConnectionTags } from '../repository/ConnectionRecord' -import { ConnectionRepository } from '../repository' +import { AgentMessage } from '../../../agent/AgentMessage' +import { EventEmitter } from '../../../agent/EventEmitter' +import { InboundMessageContext } from '../../../agent/models/InboundMessageContext' +import { signData, unpackAndVerifySignatureDecorator } from '../../../decorators/signature/SignatureDecoratorUtils' +import { AriesFrameworkError } from '../../../error' +import { Symbols } from '../../../symbols' +import { JsonTransformer } from '../../../utils/JsonTransformer' import { Wallet } from '../../../wallet/Wallet' +import { AckMessage } from '../../common' +import { ConnectionEventTypes, ConnectionStateChangedEvent } from '../ConnectionEvents' import { ConnectionInvitationMessage, ConnectionRequestMessage, ConnectionResponseMessage, TrustPingMessage, } from '../messages' -import { AckMessage } from '../../common' -import { signData, unpackAndVerifySignatureDecorator } from '../../../decorators/signature/SignatureDecoratorUtils' import { Connection, ConnectionState, @@ -25,13 +30,8 @@ import { DidCommService, IndyAgentService, } from '../models' -import { InboundMessageContext } from '../../../agent/models/InboundMessageContext' -import { JsonTransformer } from '../../../utils/JsonTransformer' -import { AgentMessage } from '../../../agent/AgentMessage' -import { Symbols } from '../../../symbols' -import { EventEmitter } from '../../../agent/EventEmitter' -import { ConnectionEventTypes, ConnectionStateChangedEvent } from '../ConnectionEvents' -import { AriesFrameworkError } from '../../../error' +import { ConnectionRepository } from '../repository' +import { ConnectionRecord, ConnectionTags } from '../repository/ConnectionRecord' @scoped(Lifecycle.ContainerScoped) export class ConnectionService { @@ -224,8 +224,14 @@ export class ConnectionService { const connectionJson = JsonTransformer.toJSON(connection) + const { threadId } = connectionRecord.tags + + if (!threadId) { + throw new AriesFrameworkError(`Connection record with id ${connectionId} does not have a thread id`) + } + const connectionResponse = new ConnectionResponseMessage({ - threadId: connectionRecord.tags.threadId!, + threadId, connectionSig: await signData(connectionJson, this.wallet, connectionRecord.verkey), }) diff --git a/src/modules/connections/services/TrustPingService.ts b/src/modules/connections/services/TrustPingService.ts index 66ae613f42..994029206d 100644 --- a/src/modules/connections/services/TrustPingService.ts +++ b/src/modules/connections/services/TrustPingService.ts @@ -2,8 +2,8 @@ import { Lifecycle, scoped } from 'tsyringe' import { createOutboundMessage } from '../../../agent/helpers' import { InboundMessageContext } from '../../../agent/models/InboundMessageContext' -import { ConnectionRecord } from '../repository/ConnectionRecord' import { TrustPingMessage, TrustPingResponseMessage } from '../messages' +import { ConnectionRecord } from '../repository/ConnectionRecord' @scoped(Lifecycle.ContainerScoped) export class TrustPingService { diff --git a/src/modules/credentials/CredentialEvents.ts b/src/modules/credentials/CredentialEvents.ts index e4ba0b1b56..d9e9180e19 100644 --- a/src/modules/credentials/CredentialEvents.ts +++ b/src/modules/credentials/CredentialEvents.ts @@ -1,4 +1,5 @@ import { BaseEvent } from '../../agent/Events' + import { CredentialState } from './CredentialState' import { CredentialRecord } from './repository/CredentialRecord' diff --git a/src/modules/credentials/CredentialUtils.ts b/src/modules/credentials/CredentialUtils.ts index 8eed36cb33..b9377044cc 100644 --- a/src/modules/credentials/CredentialUtils.ts +++ b/src/modules/credentials/CredentialUtils.ts @@ -1,6 +1,6 @@ +import BigNumber from 'bn.js' import type { CredValues } from 'indy-sdk' import { sha256 } from 'js-sha256' -import BigNumber from 'bn.js' import { CredentialPreviewAttribute } from './messages/CredentialPreview' @@ -74,7 +74,7 @@ export class CredentialUtils { * @see https://github.com/hyperledger/aries-framework-dotnet/blob/a18bef91e5b9e4a1892818df7408e2383c642dfa/src/Hyperledger.Aries/Utils/CredentialUtils.cs#L78-L89 * @see https://github.com/hyperledger/aries-rfcs/blob/be4ad0a6fb2823bb1fc109364c96f077d5d8dffa/features/0037-present-proof/README.md#verifying-claims-of-indy-based-verifiable-credentials */ - public static checkValidEncoding(raw: any, encoded: string) { + public static checkValidEncoding(raw: unknown, encoded: string) { return encoded === CredentialUtils.encode(raw) } @@ -88,28 +88,28 @@ export class CredentialUtils { * @see https://github.com/hyperledger/aries-rfcs/blob/be4ad0a6fb2823bb1fc109364c96f077d5d8dffa/features/0037-present-proof/README.md#verifying-claims-of-indy-based-verifiable-credentials * @see https://github.com/hyperledger/aries-rfcs/blob/be4ad0a6fb2823bb1fc109364c96f077d5d8dffa/features/0036-issue-credential/README.md#encoding-claims-for-indy-based-verifiable-credentials */ - public static encode(value: any) { - const isString = typeof value === 'string' - const isEmpty = isString && value === '' - const isNumber = typeof value === 'number' - const isBoolean = typeof value === 'boolean' + public static encode(value: unknown) { + const isString = (value: unknown): value is string => typeof value === 'string' + const isEmpty = (value: unknown): value is '' => isString(value) && value === '' + const isNumber = (value: unknown): value is number => typeof value === 'number' + const isBoolean = (value: unknown): value is boolean => typeof value === 'boolean' // If bool return bool as number string - if (isBoolean) { + if (isBoolean(value)) { return Number(value).toString() } // If value is int32 return as number string - if (isNumber && this.isInt32(value)) { + if (isNumber(value) && this.isInt32(value)) { return value.toString() } // If value is an int32 number string return as number string - if (isString && !isEmpty && !isNaN(Number(value)) && this.isInt32(Number(value))) { + if (isString(value) && !isEmpty(value) && !isNaN(Number(value)) && this.isInt32(Number(value))) { return value } - if (isNumber) { + if (isNumber(value)) { value = value.toString() } @@ -118,7 +118,7 @@ export class CredentialUtils { value = 'None' } - return new BigNumber(sha256.array(value)).toString() + return new BigNumber(sha256.array(value as string)).toString() } private static isInt32(number: number) { diff --git a/src/modules/credentials/CredentialsModule.ts b/src/modules/credentials/CredentialsModule.ts index 2a5fdb04e2..51de66e728 100644 --- a/src/modules/credentials/CredentialsModule.ts +++ b/src/modules/credentials/CredentialsModule.ts @@ -1,12 +1,11 @@ import { Lifecycle, scoped } from 'tsyringe' -import { CredentialRecord } from './repository/CredentialRecord' -import { createOutboundMessage } from '../../agent/helpers' +import { Dispatcher } from '../../agent/Dispatcher' import { MessageSender } from '../../agent/MessageSender' +import { createOutboundMessage } from '../../agent/helpers' +import { AriesFrameworkError } from '../../error' import { ConnectionService } from '../connections' -import { CredentialOfferTemplate, CredentialService } from './services' -import { ProposeCredentialMessageOptions } from './messages' -import { Dispatcher } from '../../agent/Dispatcher' + import { ProposeCredentialHandler, OfferCredentialHandler, @@ -14,7 +13,9 @@ import { IssueCredentialHandler, CredentialAckHandler, } from './handlers' -import { AriesFrameworkError } from '../../error' +import { ProposeCredentialMessageOptions } from './messages' +import { CredentialRecord } from './repository/CredentialRecord' +import { CredentialOfferTemplate, CredentialService } from './services' @scoped(Lifecycle.ContainerScoped) export class CredentialsModule { diff --git a/src/modules/credentials/__tests__/CredentialRecord.test.ts b/src/modules/credentials/__tests__/CredentialRecord.test.ts index f4081f7a90..511799811f 100644 --- a/src/modules/credentials/__tests__/CredentialRecord.test.ts +++ b/src/modules/credentials/__tests__/CredentialRecord.test.ts @@ -1,6 +1,6 @@ -import { CredentialRecord } from '../repository/CredentialRecord' import { CredentialState } from '../CredentialState' import { CredentialPreviewAttribute } from '../messages' +import { CredentialRecord } from '../repository/CredentialRecord' describe('CredentialRecord', () => { describe('getCredentialInfo()', () => { diff --git a/src/modules/credentials/__tests__/CredentialService.test.ts b/src/modules/credentials/__tests__/CredentialService.test.ts index 07a44efdc9..291727d519 100644 --- a/src/modules/credentials/__tests__/CredentialService.test.ts +++ b/src/modules/credentials/__tests__/CredentialService.test.ts @@ -1,7 +1,19 @@ -import { CredentialOfferTemplate, CredentialService } from '../services' -import { CredentialRecord, CredentialRecordMetadata, CredentialRecordTags } from '../repository/CredentialRecord' +import { getBaseConfig, getMockConnection, mockFunction } from '../../../__tests__/helpers' +import { AgentConfig } from '../../../agent/AgentConfig' +import { EventEmitter } from '../../../agent/EventEmitter' import { InboundMessageContext } from '../../../agent/models/InboundMessageContext' +import { Attachment, AttachmentData } from '../../../decorators/attachment/Attachment' +import { RecordNotFoundError } from '../../../error' +import { JsonEncoder } from '../../../utils/JsonEncoder' +import { AckStatus } from '../../common' +import { ConnectionService, ConnectionState } from '../../connections' +import { StoreCredentialOptions } from '../../indy' +import { IndyHolderService } from '../../indy/services/IndyHolderService' +import { IndyIssuerService } from '../../indy/services/IndyIssuerService' +import { LedgerService } from '../../ledger/services' +import { CredentialEventTypes, CredentialStateChangedEvent } from '../CredentialEvents' import { CredentialState } from '../CredentialState' +import { CredentialUtils } from '../CredentialUtils' import { OfferCredentialMessage, CredentialPreview, @@ -13,24 +25,11 @@ import { INDY_CREDENTIAL_OFFER_ATTACHMENT_ID, INDY_CREDENTIAL_ATTACHMENT_ID, } from '../messages' -import { AckStatus } from '../../common' -import { JsonEncoder } from '../../../utils/JsonEncoder' -import { credDef, credOffer, credReq } from './fixtures' -import { Attachment, AttachmentData } from '../../../decorators/attachment/Attachment' -import { ConnectionState } from '../../connections' -import { AgentConfig } from '../../../agent/AgentConfig' -import { CredentialUtils } from '../CredentialUtils' -import { StoreCredentialOptions } from '../../indy' - -// Import mocks +import { CredentialRecord, CredentialRecordMetadata, CredentialRecordTags } from '../repository/CredentialRecord' import { CredentialRepository } from '../repository/CredentialRepository' -import { LedgerService } from '../../ledger/services' -import { IndyIssuerService } from '../../indy/services/IndyIssuerService' -import { IndyHolderService } from '../../indy/services/IndyHolderService' -import { EventEmitter } from '../../../agent/EventEmitter' -import { CredentialEventTypes, CredentialStateChangedEvent } from '../CredentialEvents' -import { getBaseConfig, getMockConnection, mockFunction } from '../../../__tests__/helpers' -import { RecordNotFoundError } from '../../../error' +import { CredentialOfferTemplate, CredentialService } from '../services' + +import { credDef, credOffer, credReq } from './fixtures' // Mock classes jest.mock('../repository/CredentialRepository') @@ -146,7 +145,7 @@ describe('CredentialService', () => { credentialService = new CredentialService( credentialRepository, - { getById: () => Promise.resolve(connection) } as any, + { getById: () => Promise.resolve(connection) } as unknown as ConnectionService, ledgerService, new AgentConfig(getBaseConfig('CredentialServiceTest')), indyIssuerService, diff --git a/src/modules/credentials/__tests__/CredentialUtils.test.ts b/src/modules/credentials/__tests__/CredentialUtils.test.ts index 5181eaffaa..c3a15f1cbe 100644 --- a/src/modules/credentials/__tests__/CredentialUtils.test.ts +++ b/src/modules/credentials/__tests__/CredentialUtils.test.ts @@ -5,7 +5,7 @@ import { CredentialPreviewAttribute } from '../messages/CredentialPreview' * Sample test cases for encoding/decoding of verifiable credential claims - Aries RFCs 0036 and 0037 * @see https://gist.github.com/swcurran/78e5a9e8d11236f003f6a6263c6619a6 */ -const testEncodings: { [key: string]: { raw: any; encoded: string } } = { +const testEncodings: { [key: string]: { raw: string | number | boolean | null; encoded: string } } = { address2: { raw: '101 Wilson Lane', encoded: '68086943237164982734333428280784300550565381723532936263016368251445461241953', @@ -201,7 +201,9 @@ describe('CredentialUtils', () => { describe('checkValidEncoding', () => { // Formatted for test.each - const testEntries = Object.entries(testEncodings).map(([name, { raw, encoded }]) => [name, raw, encoded]) + const testEntries = Object.entries(testEncodings).map( + ([name, { raw, encoded }]) => [name, raw, encoded] as [string, string | number | boolean | null, string] + ) test.each(testEntries)('returns true for valid encoding %s', (_, raw, encoded) => { expect(CredentialUtils.checkValidEncoding(raw, encoded)).toEqual(true) diff --git a/src/modules/credentials/__tests__/StubWallet.ts b/src/modules/credentials/__tests__/StubWallet.ts index 7a54e70051..73654deaa2 100644 --- a/src/modules/credentials/__tests__/StubWallet.ts +++ b/src/modules/credentials/__tests__/StubWallet.ts @@ -1,7 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ import { DidConfig, WalletRecordOptions, WalletRecord, WalletQuery, LedgerRequest } from 'indy-sdk' -import { Wallet } from '../../../wallet/Wallet' + import { UnpackedMessageContext } from '../../../types' +import { Wallet } from '../../../wallet/Wallet' export class StubWallet implements Wallet { public get walletHandle() { diff --git a/src/modules/credentials/handlers/CredentialAckHandler.ts b/src/modules/credentials/handlers/CredentialAckHandler.ts index 7db5d65948..cab0dcc794 100644 --- a/src/modules/credentials/handlers/CredentialAckHandler.ts +++ b/src/modules/credentials/handlers/CredentialAckHandler.ts @@ -1,6 +1,6 @@ import { Handler, HandlerInboundMessage } from '../../../agent/Handler' -import { CredentialService } from '../services' import { CredentialAckMessage } from '../messages' +import { CredentialService } from '../services' export class CredentialAckHandler implements Handler { private credentialService: CredentialService diff --git a/src/modules/credentials/handlers/IssueCredentialHandler.ts b/src/modules/credentials/handlers/IssueCredentialHandler.ts index 83a6e6e1ad..c270293a82 100644 --- a/src/modules/credentials/handlers/IssueCredentialHandler.ts +++ b/src/modules/credentials/handlers/IssueCredentialHandler.ts @@ -1,6 +1,6 @@ import { Handler, HandlerInboundMessage } from '../../../agent/Handler' -import { CredentialService } from '../services' import { IssueCredentialMessage } from '../messages' +import { CredentialService } from '../services' export class IssueCredentialHandler implements Handler { private credentialService: CredentialService diff --git a/src/modules/credentials/handlers/OfferCredentialHandler.ts b/src/modules/credentials/handlers/OfferCredentialHandler.ts index 1f801681ab..4753ce29a6 100644 --- a/src/modules/credentials/handlers/OfferCredentialHandler.ts +++ b/src/modules/credentials/handlers/OfferCredentialHandler.ts @@ -1,6 +1,6 @@ import { Handler, HandlerInboundMessage } from '../../../agent/Handler' -import { CredentialService } from '../services' import { OfferCredentialMessage } from '../messages' +import { CredentialService } from '../services' export class OfferCredentialHandler implements Handler { private credentialService: CredentialService diff --git a/src/modules/credentials/handlers/ProposeCredentialHandler.ts b/src/modules/credentials/handlers/ProposeCredentialHandler.ts index 1a89b6bff4..486ccb5641 100644 --- a/src/modules/credentials/handlers/ProposeCredentialHandler.ts +++ b/src/modules/credentials/handlers/ProposeCredentialHandler.ts @@ -1,6 +1,6 @@ import { Handler, HandlerInboundMessage } from '../../../agent/Handler' -import { CredentialService } from '../services' import { ProposeCredentialMessage } from '../messages' +import { CredentialService } from '../services' export class ProposeCredentialHandler implements Handler { private credentialService: CredentialService diff --git a/src/modules/credentials/handlers/RequestCredentialHandler.ts b/src/modules/credentials/handlers/RequestCredentialHandler.ts index 903a23e965..7a91e31fb4 100644 --- a/src/modules/credentials/handlers/RequestCredentialHandler.ts +++ b/src/modules/credentials/handlers/RequestCredentialHandler.ts @@ -1,6 +1,6 @@ import { Handler, HandlerInboundMessage } from '../../../agent/Handler' -import { CredentialService } from '../services' import { RequestCredentialMessage } from '../messages' +import { CredentialService } from '../services' export class RequestCredentialHandler implements Handler { private credentialService: CredentialService diff --git a/src/modules/credentials/messages/CredentialAckMessage.ts b/src/modules/credentials/messages/CredentialAckMessage.ts index 406b0d5ce2..64478a0098 100644 --- a/src/modules/credentials/messages/CredentialAckMessage.ts +++ b/src/modules/credentials/messages/CredentialAckMessage.ts @@ -1,8 +1,9 @@ import { Equals } from 'class-validator' -import { IssueCredentialMessageType } from './IssueCredentialMessageType' import { AckMessage, AckMessageOptions } from '../../common' +import { IssueCredentialMessageType } from './IssueCredentialMessageType' + export type CredentialAckMessageOptions = AckMessageOptions /** diff --git a/src/modules/credentials/messages/CredentialPreview.ts b/src/modules/credentials/messages/CredentialPreview.ts index ee5607816e..a9ea173450 100644 --- a/src/modules/credentials/messages/CredentialPreview.ts +++ b/src/modules/credentials/messages/CredentialPreview.ts @@ -2,6 +2,7 @@ import { Expose, Type } from 'class-transformer' import { Equals, ValidateNested } from 'class-validator' import { JsonTransformer } from '../../../utils/JsonTransformer' + import { IssueCredentialMessageType } from './IssueCredentialMessageType' export interface CredentialPreviewOptions { diff --git a/src/modules/credentials/messages/IssueCredentialMessage.ts b/src/modules/credentials/messages/IssueCredentialMessage.ts index a9cfbc4768..c5c3e7bec4 100644 --- a/src/modules/credentials/messages/IssueCredentialMessage.ts +++ b/src/modules/credentials/messages/IssueCredentialMessage.ts @@ -1,10 +1,11 @@ -import type { Cred } from 'indy-sdk' import { Expose, Type } from 'class-transformer' import { Equals, IsArray, IsString, ValidateNested } from 'class-validator' +import type { Cred } from 'indy-sdk' import { AgentMessage } from '../../../agent/AgentMessage' import { Attachment } from '../../../decorators/attachment/Attachment' import { JsonEncoder } from '../../../utils/JsonEncoder' + import { IssueCredentialMessageType } from './IssueCredentialMessageType' export const INDY_CREDENTIAL_ATTACHMENT_ID = 'libindy-cred-0' diff --git a/src/modules/credentials/messages/OfferCredentialMessage.ts b/src/modules/credentials/messages/OfferCredentialMessage.ts index 2a126c9261..a364059238 100644 --- a/src/modules/credentials/messages/OfferCredentialMessage.ts +++ b/src/modules/credentials/messages/OfferCredentialMessage.ts @@ -1,13 +1,14 @@ -import type { CredOffer } from 'indy-sdk' -import { Equals, IsArray, IsString, ValidateNested } from 'class-validator' import { Expose, Type } from 'class-transformer' +import { Equals, IsArray, IsString, ValidateNested } from 'class-validator' +import type { CredOffer } from 'indy-sdk' import { AgentMessage } from '../../../agent/AgentMessage' -import { IssueCredentialMessageType } from './IssueCredentialMessageType' import { Attachment } from '../../../decorators/attachment/Attachment' -import { CredentialPreview } from './CredentialPreview' import { JsonEncoder } from '../../../utils/JsonEncoder' +import { CredentialPreview } from './CredentialPreview' +import { IssueCredentialMessageType } from './IssueCredentialMessageType' + export const INDY_CREDENTIAL_OFFER_ATTACHMENT_ID = 'libindy-cred-offer-0' export interface OfferCredentialMessageOptions { diff --git a/src/modules/credentials/messages/ProposeCredentialMessage.ts b/src/modules/credentials/messages/ProposeCredentialMessage.ts index 6b48f34af6..85b818dd3c 100644 --- a/src/modules/credentials/messages/ProposeCredentialMessage.ts +++ b/src/modules/credentials/messages/ProposeCredentialMessage.ts @@ -2,6 +2,7 @@ import { Expose, Type } from 'class-transformer' import { Equals, IsOptional, IsString, ValidateNested } from 'class-validator' import { AgentMessage } from '../../../agent/AgentMessage' + import { CredentialPreview } from './CredentialPreview' import { IssueCredentialMessageType } from './IssueCredentialMessageType' diff --git a/src/modules/credentials/messages/RequestCredentialMessage.ts b/src/modules/credentials/messages/RequestCredentialMessage.ts index 422039d8fe..aec27dcfa1 100644 --- a/src/modules/credentials/messages/RequestCredentialMessage.ts +++ b/src/modules/credentials/messages/RequestCredentialMessage.ts @@ -1,11 +1,13 @@ -import type { CredReq } from 'indy-sdk' +import { Expose, Type } from 'class-transformer' import { Equals, IsArray, IsString, ValidateNested } from 'class-validator' +import type { CredReq } from 'indy-sdk' + import { AgentMessage } from '../../../agent/AgentMessage' -import { IssueCredentialMessageType } from './IssueCredentialMessageType' -import { Expose, Type } from 'class-transformer' import { Attachment } from '../../../decorators/attachment/Attachment' import { JsonEncoder } from '../../../utils/JsonEncoder' +import { IssueCredentialMessageType } from './IssueCredentialMessageType' + export const INDY_CREDENTIAL_REQUEST_ATTACHMENT_ID = 'libindy-cred-request-0' interface RequestCredentialMessageOptions { diff --git a/src/modules/credentials/models/Credential.ts b/src/modules/credentials/models/Credential.ts index 8c9f4c340b..a97a0f53e9 100644 --- a/src/modules/credentials/models/Credential.ts +++ b/src/modules/credentials/models/Credential.ts @@ -1,6 +1,7 @@ -import type { IndyCredential } from 'indy-sdk' import { Expose, Type } from 'class-transformer' import { IsOptional, ValidateNested } from 'class-validator' +import type { IndyCredential } from 'indy-sdk' + import { JsonTransformer } from '../../../utils/JsonTransformer' import { IndyCredentialInfo } from './IndyCredentialInfo' diff --git a/src/modules/credentials/models/IndyCredentialInfo.ts b/src/modules/credentials/models/IndyCredentialInfo.ts index 5000bd6a86..2a90a4f242 100644 --- a/src/modules/credentials/models/IndyCredentialInfo.ts +++ b/src/modules/credentials/models/IndyCredentialInfo.ts @@ -1,6 +1,6 @@ -import type { IndyCredentialInfo as IndySDKCredentialInfo } from 'indy-sdk' import { Expose } from 'class-transformer' import { IsOptional, IsString } from 'class-validator' +import type { IndyCredentialInfo as IndySDKCredentialInfo } from 'indy-sdk' import { JsonTransformer } from '../../../utils/JsonTransformer' diff --git a/src/modules/credentials/repository/CredentialRecord.ts b/src/modules/credentials/repository/CredentialRecord.ts index 4ed8115c08..e35d2ee3d8 100644 --- a/src/modules/credentials/repository/CredentialRecord.ts +++ b/src/modules/credentials/repository/CredentialRecord.ts @@ -1,6 +1,9 @@ import { Type } from 'class-transformer' -import { uuid } from '../../../utils/uuid' + +import { AriesFrameworkError } from '../../../error' import { BaseRecord, Tags } from '../../../storage/BaseRecord' +import { uuid } from '../../../utils/uuid' +import { CredentialState } from '../CredentialState' import { ProposeCredentialMessage, IssueCredentialMessage, @@ -8,9 +11,7 @@ import { OfferCredentialMessage, CredentialPreviewAttribute, } from '../messages' -import { CredentialState } from '../CredentialState' import { CredentialInfo } from '../models/CredentialInfo' -import { AriesFrameworkError } from '../../../error' export interface CredentialRecordMetadata { requestMetadata?: Record diff --git a/src/modules/credentials/repository/CredentialRepository.ts b/src/modules/credentials/repository/CredentialRepository.ts index 0f5a5d1921..9a74b2c701 100644 --- a/src/modules/credentials/repository/CredentialRepository.ts +++ b/src/modules/credentials/repository/CredentialRepository.ts @@ -1,10 +1,11 @@ import { inject, scoped, Lifecycle } from 'tsyringe' import { Repository } from '../../../storage/Repository' -import { CredentialRecord } from './CredentialRecord' import { StorageService } from '../../../storage/StorageService' import { Symbols } from '../../../symbols' +import { CredentialRecord } from './CredentialRecord' + @scoped(Lifecycle.ContainerScoped) export class CredentialRepository extends Repository { public constructor(@inject(Symbols.StorageService) storageService: StorageService) { diff --git a/src/modules/credentials/services/CredentialService.ts b/src/modules/credentials/services/CredentialService.ts index 1a273b9dd6..426fa17c04 100644 --- a/src/modules/credentials/services/CredentialService.ts +++ b/src/modules/credentials/services/CredentialService.ts @@ -1,15 +1,20 @@ -import { scoped, Lifecycle } from 'tsyringe' import type { CredDefId } from 'indy-sdk' +import { scoped, Lifecycle } from 'tsyringe' -import { uuid } from '../../../utils/uuid' +import { AgentConfig } from '../../../agent/AgentConfig' import { AgentMessage } from '../../../agent/AgentMessage' -import { LedgerService } from '../../ledger/services/LedgerService' +import { EventEmitter } from '../../../agent/EventEmitter' import { InboundMessageContext } from '../../../agent/models/InboundMessageContext' import { Attachment, AttachmentData } from '../../../decorators/attachment/Attachment' -import { ConnectionService, ConnectionRecord } from '../../connections' -import { CredentialRecord } from '../repository/CredentialRecord' +import { AriesFrameworkError } from '../../../error' +import { Logger } from '../../../logger' import { JsonEncoder } from '../../../utils/JsonEncoder' - +import { uuid } from '../../../utils/uuid' +import { AckStatus } from '../../common' +import { ConnectionService, ConnectionRecord } from '../../connections' +import { IndyIssuerService, IndyHolderService } from '../../indy' +import { LedgerService } from '../../ledger/services/LedgerService' +import { CredentialEventTypes, CredentialStateChangedEvent } from '../CredentialEvents' import { CredentialState } from '../CredentialState' import { CredentialUtils } from '../CredentialUtils' import { @@ -24,14 +29,8 @@ import { ProposeCredentialMessage, ProposeCredentialMessageOptions, } from '../messages' -import { AckStatus } from '../../common' -import { Logger } from '../../../logger' -import { AgentConfig } from '../../../agent/AgentConfig' import { CredentialRepository } from '../repository' -import { IndyIssuerService, IndyHolderService } from '../../indy' -import { CredentialEventTypes, CredentialStateChangedEvent } from '../CredentialEvents' -import { EventEmitter } from '../../../agent/EventEmitter' -import { AriesFrameworkError } from '../../../error' +import { CredentialRecord } from '../repository/CredentialRecord' @scoped(Lifecycle.ContainerScoped) export class CredentialService { @@ -616,7 +615,7 @@ export class CredentialService { // Create message const ackMessage = new CredentialAckMessage({ status: AckStatus.OK, - threadId: credentialRecord.tags.threadId!, + threadId: credentialRecord.tags.threadId, }) await this.updateState(credentialRecord, CredentialState.Done) diff --git a/src/modules/indy/services/IndyIssuerService.ts b/src/modules/indy/services/IndyIssuerService.ts index 901b7b044a..fbc74f2468 100644 --- a/src/modules/indy/services/IndyIssuerService.ts +++ b/src/modules/indy/services/IndyIssuerService.ts @@ -1,5 +1,5 @@ -import type Indy from 'indy-sdk' import type { + default as Indy, CredDef, Schema, Cred, diff --git a/src/modules/ledger/LedgerModule.ts b/src/modules/ledger/LedgerModule.ts index 1804a862ff..050fa571aa 100644 --- a/src/modules/ledger/LedgerModule.ts +++ b/src/modules/ledger/LedgerModule.ts @@ -1,10 +1,11 @@ import type { CredDefId, Did, SchemaId } from 'indy-sdk' import { inject, scoped, Lifecycle } from 'tsyringe' -import { LedgerService, SchemaTemplate, CredentialDefinitionTemplate } from './services' -import { Wallet } from '../../wallet/Wallet' -import { Symbols } from '../../symbols' import { AriesFrameworkError } from '../../error' +import { Symbols } from '../../symbols' +import { Wallet } from '../../wallet/Wallet' + +import { LedgerService, SchemaTemplate, CredentialDefinitionTemplate } from './services' @scoped(Lifecycle.ContainerScoped) export class LedgerModule { diff --git a/src/modules/ledger/services/LedgerService.ts b/src/modules/ledger/services/LedgerService.ts index d9e5b6cac1..eb88f99045 100644 --- a/src/modules/ledger/services/LedgerService.ts +++ b/src/modules/ledger/services/LedgerService.ts @@ -1,6 +1,5 @@ -import { inject, scoped, Lifecycle } from 'tsyringe' -import type Indy from 'indy-sdk' import type { + default as Indy, CredDef, CredDefId, Did, @@ -11,13 +10,15 @@ import type { LedgerReadReplyResponse, LedgerWriteReplyResponse, } from 'indy-sdk' +import { inject, scoped, Lifecycle } from 'tsyringe' + import { AgentConfig } from '../../../agent/AgentConfig' import { Logger } from '../../../logger' +import { FileSystem } from '../../../storage/fs/FileSystem' +import { Symbols } from '../../../symbols' import { isIndyError } from '../../../utils/indyError' import { Wallet } from '../../../wallet/Wallet' -import { Symbols } from '../../../symbols' import { IndyIssuerService } from '../../indy' -import { FileSystem } from '../../../storage/fs/FileSystem' @scoped(Lifecycle.ContainerScoped) export class LedgerService { diff --git a/src/modules/proofs/ProofEvents.ts b/src/modules/proofs/ProofEvents.ts index f8715652a7..0b7e42f483 100644 --- a/src/modules/proofs/ProofEvents.ts +++ b/src/modules/proofs/ProofEvents.ts @@ -1,4 +1,5 @@ import { BaseEvent } from '../../agent/Events' + import { ProofState } from './ProofState' import { ProofRecord } from './repository' diff --git a/src/modules/proofs/ProofsModule.ts b/src/modules/proofs/ProofsModule.ts index 404655bcea..6dc60806ef 100644 --- a/src/modules/proofs/ProofsModule.ts +++ b/src/modules/proofs/ProofsModule.ts @@ -1,21 +1,22 @@ import { Lifecycle, scoped } from 'tsyringe' -import { createOutboundMessage } from '../../agent/helpers' +import { Dispatcher } from '../../agent/Dispatcher' import { MessageSender } from '../../agent/MessageSender' +import { createOutboundMessage } from '../../agent/helpers' +import { AriesFrameworkError } from '../../error' import { ConnectionService } from '../connections' -import { ProofService } from './services' -import { ProofRecord } from './repository/ProofRecord' -import { ProofRequest } from './models/ProofRequest' -import { PresentationPreview } from './messages' -import { RequestedCredentials } from './models' -import { Dispatcher } from '../../agent/Dispatcher' + import { ProposePresentationHandler, RequestPresentationHandler, PresentationAckHandler, PresentationHandler, } from './handlers' -import { AriesFrameworkError } from '../../error' +import { PresentationPreview } from './messages' +import { RequestedCredentials } from './models' +import { ProofRequest } from './models/ProofRequest' +import { ProofRecord } from './repository/ProofRecord' +import { ProofService } from './services' @scoped(Lifecycle.ContainerScoped) export class ProofsModule { diff --git a/src/modules/proofs/handlers/PresentationAckHandler.ts b/src/modules/proofs/handlers/PresentationAckHandler.ts index 2d868e76c5..ee66121155 100644 --- a/src/modules/proofs/handlers/PresentationAckHandler.ts +++ b/src/modules/proofs/handlers/PresentationAckHandler.ts @@ -1,6 +1,6 @@ import { Handler, HandlerInboundMessage } from '../../../agent/Handler' -import { ProofService } from '../services' import { PresentationAckMessage } from '../messages' +import { ProofService } from '../services' export class PresentationAckHandler implements Handler { private proofService: ProofService diff --git a/src/modules/proofs/messages/PresentationAckMessage.ts b/src/modules/proofs/messages/PresentationAckMessage.ts index e77ed00019..d49a3c85a0 100644 --- a/src/modules/proofs/messages/PresentationAckMessage.ts +++ b/src/modules/proofs/messages/PresentationAckMessage.ts @@ -1,6 +1,7 @@ import { Equals } from 'class-validator' import { AckMessage, AckMessageOptions } from '../../common' + import { PresentProofMessageType } from './PresentProofMessageType' export type PresentationAckMessageOptions = AckMessageOptions diff --git a/src/modules/proofs/messages/PresentationMessage.ts b/src/modules/proofs/messages/PresentationMessage.ts index 78044ff65f..1b5f9378df 100644 --- a/src/modules/proofs/messages/PresentationMessage.ts +++ b/src/modules/proofs/messages/PresentationMessage.ts @@ -1,10 +1,11 @@ -import type { IndyProof } from 'indy-sdk' -import { Equals, IsArray, IsString, ValidateNested, IsOptional } from 'class-validator' import { Expose, Type } from 'class-transformer' +import { Equals, IsArray, IsString, ValidateNested, IsOptional } from 'class-validator' +import type { IndyProof } from 'indy-sdk' import { AgentMessage } from '../../../agent/AgentMessage' import { Attachment } from '../../../decorators/attachment/Attachment' import { JsonEncoder } from '../../../utils/JsonEncoder' + import { PresentProofMessageType } from './PresentProofMessageType' export const INDY_PROOF_ATTACHMENT_ID = 'libindy-presentation-0' diff --git a/src/modules/proofs/messages/PresentationPreview.ts b/src/modules/proofs/messages/PresentationPreview.ts index 9b67f2a417..a23bfd8347 100644 --- a/src/modules/proofs/messages/PresentationPreview.ts +++ b/src/modules/proofs/messages/PresentationPreview.ts @@ -1,10 +1,11 @@ -import { Equals, IsEnum, IsInt, IsString, ValidateIf, ValidateNested } from 'class-validator' import { Expose, Type } from 'class-transformer' +import { Equals, IsEnum, IsInt, IsString, ValidateIf, ValidateNested } from 'class-validator' -import { PresentProofMessageType } from './PresentProofMessageType' import { JsonTransformer } from '../../../utils/JsonTransformer' import { PredicateType } from '../models/PredicateType' +import { PresentProofMessageType } from './PresentProofMessageType' + export interface PresentationPreviewOptions { attributes?: PresentationPreviewAttribute[] predicates?: PresentationPreviewPredicate[] diff --git a/src/modules/proofs/messages/ProposePresentationMessage.ts b/src/modules/proofs/messages/ProposePresentationMessage.ts index db3c698f77..47bcaefd48 100644 --- a/src/modules/proofs/messages/ProposePresentationMessage.ts +++ b/src/modules/proofs/messages/ProposePresentationMessage.ts @@ -1,7 +1,8 @@ -import { Equals, IsOptional, IsString, ValidateNested } from 'class-validator' import { Expose, Type } from 'class-transformer' +import { Equals, IsOptional, IsString, ValidateNested } from 'class-validator' import { AgentMessage } from '../../../agent/AgentMessage' + import { PresentProofMessageType } from './PresentProofMessageType' import { PresentationPreview } from './PresentationPreview' diff --git a/src/modules/proofs/messages/RequestPresentationMessage.ts b/src/modules/proofs/messages/RequestPresentationMessage.ts index bb349bc4a9..d5d7591bab 100644 --- a/src/modules/proofs/messages/RequestPresentationMessage.ts +++ b/src/modules/proofs/messages/RequestPresentationMessage.ts @@ -1,11 +1,12 @@ -import { Equals, IsArray, IsString, ValidateNested, IsOptional } from 'class-validator' import { Expose, Type } from 'class-transformer' +import { Equals, IsArray, IsString, ValidateNested, IsOptional } from 'class-validator' import { AgentMessage } from '../../../agent/AgentMessage' import { Attachment } from '../../../decorators/attachment/Attachment' import { JsonEncoder } from '../../../utils/JsonEncoder' import { JsonTransformer } from '../../../utils/JsonTransformer' import { ProofRequest } from '../models' + import { PresentProofMessageType } from './PresentProofMessageType' export interface RequestPresentationOptions { diff --git a/src/modules/proofs/models/ProofAttribute.ts b/src/modules/proofs/models/ProofAttribute.ts index a9f62d0b7b..07bd96d4b9 100644 --- a/src/modules/proofs/models/ProofAttribute.ts +++ b/src/modules/proofs/models/ProofAttribute.ts @@ -1,5 +1,5 @@ -import { IsInt, IsPositive, IsString } from 'class-validator' import { Expose } from 'class-transformer' +import { IsInt, IsPositive, IsString } from 'class-validator' export class ProofAttribute { public constructor(options: ProofAttribute) { diff --git a/src/modules/proofs/models/ProofAttributeInfo.ts b/src/modules/proofs/models/ProofAttributeInfo.ts index 67a282357f..34557b378f 100644 --- a/src/modules/proofs/models/ProofAttributeInfo.ts +++ b/src/modules/proofs/models/ProofAttributeInfo.ts @@ -1,9 +1,10 @@ import { Expose, Type } from 'class-transformer' import { IsString, IsOptional, IsArray, ValidateNested } from 'class-validator' -import { AttributeFilter } from './AttributeFilter' import { RevocationInterval } from '../../credentials' +import { AttributeFilter } from './AttributeFilter' + export class ProofAttributeInfo { public constructor(options: ProofAttributeInfo) { if (options) { diff --git a/src/modules/proofs/models/ProofPredicateInfo.ts b/src/modules/proofs/models/ProofPredicateInfo.ts index 2775b86acd..f8e799c827 100644 --- a/src/modules/proofs/models/ProofPredicateInfo.ts +++ b/src/modules/proofs/models/ProofPredicateInfo.ts @@ -1,9 +1,10 @@ import { Expose, Type } from 'class-transformer' import { IsArray, IsEnum, IsInt, IsOptional, IsString, ValidateNested } from 'class-validator' +import { RevocationInterval } from '../../credentials' + import { AttributeFilter } from './AttributeFilter' import { PredicateType } from './PredicateType' -import { RevocationInterval } from '../../credentials' export class ProofPredicateInfo { public constructor(options: ProofPredicateInfo) { diff --git a/src/modules/proofs/models/ProofRequest.ts b/src/modules/proofs/models/ProofRequest.ts index 68f44778c9..019019df97 100644 --- a/src/modules/proofs/models/ProofRequest.ts +++ b/src/modules/proofs/models/ProofRequest.ts @@ -1,15 +1,15 @@ -import type { IndyProofRequest } from 'indy-sdk' -import { IsString, ValidateNested, IsOptional, IsIn } from 'class-validator' import { Expose, Type } from 'class-transformer' +import { IsString, ValidateNested, IsOptional, IsIn } from 'class-validator' +import type { IndyProofRequest } from 'indy-sdk' +import { JsonTransformer } from '../../../utils/JsonTransformer' +import { RecordTransformer } from '../../../utils/transformers' +import { Optional } from '../../../utils/type' import { RevocationInterval } from '../../credentials' + import { ProofAttributeInfo } from './ProofAttributeInfo' import { ProofPredicateInfo } from './ProofPredicateInfo' -import { JsonTransformer } from '../../../utils/JsonTransformer' -import { Optional } from '../../../utils/type' -import { RecordTransformer } from '../../../utils/transformers' - /** * Proof Request for Indy based proof format * diff --git a/src/modules/proofs/models/RequestedAttribute.ts b/src/modules/proofs/models/RequestedAttribute.ts index fa405094e2..2c36456206 100644 --- a/src/modules/proofs/models/RequestedAttribute.ts +++ b/src/modules/proofs/models/RequestedAttribute.ts @@ -1,5 +1,5 @@ -import { IsBoolean, IsInt, IsOptional, IsPositive, IsString } from 'class-validator' import { Expose } from 'class-transformer' +import { IsBoolean, IsInt, IsOptional, IsPositive, IsString } from 'class-validator' /** * Requested Attribute for Indy proof creation diff --git a/src/modules/proofs/models/RequestedCredentials.ts b/src/modules/proofs/models/RequestedCredentials.ts index 0f8025516c..82868c6f90 100644 --- a/src/modules/proofs/models/RequestedCredentials.ts +++ b/src/modules/proofs/models/RequestedCredentials.ts @@ -1,12 +1,13 @@ -import type { IndyRequestedCredentials } from 'indy-sdk' -import { ValidateNested } from 'class-validator' import { Expose, Type } from 'class-transformer' +import { ValidateNested } from 'class-validator' +import type { IndyRequestedCredentials } from 'indy-sdk' -import { RequestedAttribute } from './RequestedAttribute' -import { RequestedPredicate } from './RequestedPredicate' import { JsonTransformer } from '../../../utils/JsonTransformer' import { RecordTransformer } from '../../../utils/transformers' +import { RequestedAttribute } from './RequestedAttribute' +import { RequestedPredicate } from './RequestedPredicate' + interface RequestedCredentialsOptions { requestedAttributes?: Record requestedPredicates?: Record diff --git a/src/modules/proofs/models/RequestedPredicate.ts b/src/modules/proofs/models/RequestedPredicate.ts index ebb5c8b3b5..b8be98be6a 100644 --- a/src/modules/proofs/models/RequestedPredicate.ts +++ b/src/modules/proofs/models/RequestedPredicate.ts @@ -1,5 +1,5 @@ -import { IsInt, IsOptional, IsPositive, IsString } from 'class-validator' import { Expose } from 'class-transformer' +import { IsInt, IsOptional, IsPositive, IsString } from 'class-validator' /** * Requested Predicate for Indy proof creation diff --git a/src/modules/proofs/models/RequestedProof.ts b/src/modules/proofs/models/RequestedProof.ts index 020c2c36d3..4f72925570 100644 --- a/src/modules/proofs/models/RequestedProof.ts +++ b/src/modules/proofs/models/RequestedProof.ts @@ -1,5 +1,5 @@ -import { IsString, ValidateNested } from 'class-validator' import { Expose, Type } from 'class-transformer' +import { IsString, ValidateNested } from 'class-validator' import { ProofAttribute } from './ProofAttribute' diff --git a/src/modules/proofs/repository/ProofRecord.ts b/src/modules/proofs/repository/ProofRecord.ts index d7a5710cd0..75c95ed305 100644 --- a/src/modules/proofs/repository/ProofRecord.ts +++ b/src/modules/proofs/repository/ProofRecord.ts @@ -1,10 +1,10 @@ import { Type } from 'class-transformer' -import { uuid } from '../../../utils/uuid' +import { AriesFrameworkError } from '../../../error' import { BaseRecord, Tags } from '../../../storage/BaseRecord' -import { ProposePresentationMessage, RequestPresentationMessage, PresentationMessage } from '../messages' +import { uuid } from '../../../utils/uuid' import { ProofState } from '../ProofState' -import { AriesFrameworkError } from '../../../error' +import { ProposePresentationMessage, RequestPresentationMessage, PresentationMessage } from '../messages' export interface ProofRecordProps { id?: string diff --git a/src/modules/proofs/repository/ProofRepository.ts b/src/modules/proofs/repository/ProofRepository.ts index bfadc03722..96e0021e70 100644 --- a/src/modules/proofs/repository/ProofRepository.ts +++ b/src/modules/proofs/repository/ProofRepository.ts @@ -1,10 +1,11 @@ import { inject, scoped, Lifecycle } from 'tsyringe' import { Repository } from '../../../storage/Repository' -import { ProofRecord } from './ProofRecord' import { StorageService } from '../../../storage/StorageService' import { Symbols } from '../../../symbols' +import { ProofRecord } from './ProofRecord' + @scoped(Lifecycle.ContainerScoped) export class ProofRepository extends Repository { public constructor(@inject(Symbols.StorageService) storageService: StorageService) { diff --git a/src/modules/proofs/services/ProofService.ts b/src/modules/proofs/services/ProofService.ts index 6a2d5ed44d..3049ece6ad 100644 --- a/src/modules/proofs/services/ProofService.ts +++ b/src/modules/proofs/services/ProofService.ts @@ -1,19 +1,26 @@ -import { inject, scoped, Lifecycle } from 'tsyringe' -import type { IndyProof, Schema, CredDef } from 'indy-sdk' import { validateOrReject } from 'class-validator' +import type { IndyProof, Schema, CredDef } from 'indy-sdk' +import { inject, scoped, Lifecycle } from 'tsyringe' +import { AgentConfig } from '../../../agent/AgentConfig' import { AgentMessage } from '../../../agent/AgentMessage' -import { LedgerService } from '../../ledger/services/LedgerService' +import { EventEmitter } from '../../../agent/EventEmitter' import { InboundMessageContext } from '../../../agent/models/InboundMessageContext' import { Attachment, AttachmentData } from '../../../decorators/attachment/Attachment' -import { ConnectionRecord } from '../../connections' -import { ProofRecord } from '../repository/ProofRecord' +import { AriesFrameworkError } from '../../../error' +import { Logger } from '../../../logger' +import { Symbols } from '../../../symbols' import { JsonEncoder } from '../../../utils/JsonEncoder' import { JsonTransformer } from '../../../utils/JsonTransformer' import { uuid } from '../../../utils/uuid' import { Wallet } from '../../../wallet/Wallet' +import { AckStatus } from '../../common' +import { ConnectionRecord } from '../../connections' import { CredentialUtils, Credential, IndyCredentialInfo } from '../../credentials' - +import { IndyHolderService, IndyVerifierService } from '../../indy' +import { LedgerService } from '../../ledger/services/LedgerService' +import { ProofEventTypes, ProofStateChangedEvent } from '../ProofEvents' +import { ProofState } from '../ProofState' import { PresentationMessage, PresentationPreview, @@ -24,7 +31,6 @@ import { INDY_PROOF_REQUEST_ATTACHMENT_ID, INDY_PROOF_ATTACHMENT_ID, } from '../messages' -import { AckStatus } from '../../common' import { PartialProof, ProofAttributeInfo, @@ -35,15 +41,8 @@ import { RequestedAttribute, RequestedPredicate, } from '../models' -import { ProofState } from '../ProofState' -import { AgentConfig } from '../../../agent/AgentConfig' -import { Logger } from '../../../logger' import { ProofRepository } from '../repository' -import { Symbols } from '../../../symbols' -import { IndyHolderService, IndyVerifierService } from '../../indy' -import { EventEmitter } from '../../../agent/EventEmitter' -import { ProofEventTypes, ProofStateChangedEvent } from '../ProofEvents' -import { AriesFrameworkError } from '../../../error' +import { ProofRecord } from '../repository/ProofRecord' /** * @todo add method to check if request matches proposal. Useful to see if a request I received is the same as the proposal I sent. @@ -483,7 +482,7 @@ export class ProofService { // Create message const ackMessage = new PresentationAckMessage({ status: AckStatus.OK, - threadId: proofRecord.tags.threadId!, + threadId: proofRecord.tags.threadId, }) // Update record diff --git a/src/modules/routing/RoutingModule.ts b/src/modules/routing/RoutingModule.ts index 0f9af23144..c376b2e482 100644 --- a/src/modules/routing/RoutingModule.ts +++ b/src/modules/routing/RoutingModule.ts @@ -1,12 +1,16 @@ -import { Lifecycle, scoped } from 'tsyringe' import type { Verkey } from 'indy-sdk' +import { Lifecycle, scoped } from 'tsyringe' import { AgentConfig } from '../../agent/AgentConfig' -import { ProviderRoutingService, MessagePickupService, ProvisioningService } from './services' +import { Dispatcher } from '../../agent/Dispatcher' +import { EventEmitter } from '../../agent/EventEmitter' import { MessageSender } from '../../agent/MessageSender' import { createOutboundMessage } from '../../agent/helpers' -import { ConnectionService, ConnectionState, ConnectionInvitationMessage } from '../connections' -import { Dispatcher } from '../../agent/Dispatcher' +import { ReturnRouteTypes } from '../../decorators/transport/TransportDecorator' +import { Logger } from '../../logger' +import { ConnectionService, ConnectionState } from '../connections' +import { ConnectionInvitationMessage } from '../connections/messages/ConnectionInvitationMessage' + import { BatchHandler, BatchPickupHandler, @@ -14,10 +18,7 @@ import { KeylistUpdateHandler, KeylistUpdateResponseHandler, } from './handlers' -import { Logger } from '../../logger' -import { ReturnRouteTypes } from '../../decorators/transport/TransportDecorator' -import { EventEmitter } from '../../agent/EventEmitter' -import { AriesFrameworkError } from '../../error' +import { ProviderRoutingService, MessagePickupService, ProvisioningService } from './services' @scoped(Lifecycle.ContainerScoped) export class RoutingModule { diff --git a/src/modules/routing/handlers/BatchHandler.ts b/src/modules/routing/handlers/BatchHandler.ts index 1dddf4ccb6..46869265b8 100644 --- a/src/modules/routing/handlers/BatchHandler.ts +++ b/src/modules/routing/handlers/BatchHandler.ts @@ -2,7 +2,6 @@ import { EventEmitter } from '../../../agent/EventEmitter' import { AgentEventTypes, AgentMessageReceivedEvent } from '../../../agent/Events' import { Handler, HandlerInboundMessage } from '../../../agent/Handler' import { AriesFrameworkError } from '../../../error' - import { BatchMessage } from '../messages' export class BatchHandler implements Handler { diff --git a/src/modules/routing/handlers/BatchPickupHandler.ts b/src/modules/routing/handlers/BatchPickupHandler.ts index cf9eba0f9b..9fa386ef20 100644 --- a/src/modules/routing/handlers/BatchPickupHandler.ts +++ b/src/modules/routing/handlers/BatchPickupHandler.ts @@ -1,7 +1,7 @@ import { Handler, HandlerInboundMessage } from '../../../agent/Handler' -import { MessagePickupService } from '../services' -import { BatchPickupMessage } from '../messages' import { AriesFrameworkError } from '../../../error' +import { BatchPickupMessage } from '../messages' +import { MessagePickupService } from '../services' export class BatchPickupHandler implements Handler { private messagePickupService: MessagePickupService diff --git a/src/modules/routing/handlers/ForwardHandler.ts b/src/modules/routing/handlers/ForwardHandler.ts index c47c8165c9..014d640e3a 100644 --- a/src/modules/routing/handlers/ForwardHandler.ts +++ b/src/modules/routing/handlers/ForwardHandler.ts @@ -1,6 +1,6 @@ import { Handler, HandlerInboundMessage } from '../../../agent/Handler' -import { ProviderRoutingService } from '../services' import { ForwardMessage } from '../messages' +import { ProviderRoutingService } from '../services' export class ForwardHandler implements Handler { private routingService: ProviderRoutingService diff --git a/src/modules/routing/handlers/KeylistUpdateHandler.ts b/src/modules/routing/handlers/KeylistUpdateHandler.ts index c0f517a81d..c985779aa5 100644 --- a/src/modules/routing/handlers/KeylistUpdateHandler.ts +++ b/src/modules/routing/handlers/KeylistUpdateHandler.ts @@ -1,8 +1,8 @@ import { Handler, HandlerInboundMessage } from '../../../agent/Handler' -import { ProviderRoutingService } from '../services' -import { KeylistUpdateMessage } from '../messages' import { createOutboundMessage } from '../../../agent/helpers' import { AriesFrameworkError } from '../../../error' +import { KeylistUpdateMessage } from '../messages' +import { ProviderRoutingService } from '../services' export class KeylistUpdateHandler implements Handler { private routingService: ProviderRoutingService diff --git a/src/modules/routing/handlers/KeylistUpdateResponseHandler.ts b/src/modules/routing/handlers/KeylistUpdateResponseHandler.ts index 61e6400acf..03b281c4c0 100644 --- a/src/modules/routing/handlers/KeylistUpdateResponseHandler.ts +++ b/src/modules/routing/handlers/KeylistUpdateResponseHandler.ts @@ -1,10 +1,10 @@ -import { Handler, HandlerInboundMessage } from '../../../agent/Handler' +import { Handler } from '../../../agent/Handler' import { KeylistUpdateResponseMessage } from '../messages' export class KeylistUpdateResponseHandler implements Handler { public supportedMessages = [KeylistUpdateResponseMessage] - public async handle(messageContext: HandlerInboundMessage) { + public async handle() { // TODO It should handle the response when agent calls `await this.consumerRoutingService.createRoute(connectionRecord.verkey)` and notify about the result. } } diff --git a/src/modules/routing/messages/BatchMessage.ts b/src/modules/routing/messages/BatchMessage.ts index 6a32c85718..a2db1cb756 100644 --- a/src/modules/routing/messages/BatchMessage.ts +++ b/src/modules/routing/messages/BatchMessage.ts @@ -1,11 +1,12 @@ -import { Equals, Matches, IsArray, ValidateNested } from 'class-validator' import { Type, Expose } from 'class-transformer' -import { uuid } from '../../../utils/uuid' +import { Equals, Matches, IsArray, ValidateNested } from 'class-validator' -import { MessageIdRegExp } from '../../../agent/BaseMessage' import { AgentMessage } from '../../../agent/AgentMessage' -import { RoutingMessageType as MessageType } from './RoutingMessageType' +import { MessageIdRegExp } from '../../../agent/BaseMessage' import { WireMessage } from '../../../types' +import { uuid } from '../../../utils/uuid' + +import { RoutingMessageType as MessageType } from './RoutingMessageType' export interface BatchMessageOptions { id?: string diff --git a/src/modules/routing/messages/BatchPickupMessage.ts b/src/modules/routing/messages/BatchPickupMessage.ts index e7196fbd4e..08c0b924ab 100644 --- a/src/modules/routing/messages/BatchPickupMessage.ts +++ b/src/modules/routing/messages/BatchPickupMessage.ts @@ -1,7 +1,8 @@ -import { Equals, IsNumber } from 'class-validator' import { Expose } from 'class-transformer' +import { Equals, IsNumber } from 'class-validator' import { AgentMessage } from '../../../agent/AgentMessage' + import { RoutingMessageType as MessageType } from './RoutingMessageType' export interface BatchPickupMessageOptions { diff --git a/src/modules/routing/messages/ForwardMessage.ts b/src/modules/routing/messages/ForwardMessage.ts index e75ff35c3b..66ace155a1 100644 --- a/src/modules/routing/messages/ForwardMessage.ts +++ b/src/modules/routing/messages/ForwardMessage.ts @@ -1,7 +1,8 @@ -import { Equals, IsString } from 'class-validator' import { Expose } from 'class-transformer' +import { Equals, IsString } from 'class-validator' import { AgentMessage } from '../../../agent/AgentMessage' + import { RoutingMessageType as MessageType } from './RoutingMessageType' export interface ForwardMessageOptions { diff --git a/src/modules/routing/messages/KeylistUpdateMessage.ts b/src/modules/routing/messages/KeylistUpdateMessage.ts index e16a20dbfe..2bfa4ec6bd 100644 --- a/src/modules/routing/messages/KeylistUpdateMessage.ts +++ b/src/modules/routing/messages/KeylistUpdateMessage.ts @@ -1,8 +1,9 @@ -import type { Verkey } from 'indy-sdk' -import { Equals, IsArray, ValidateNested, IsString, IsEnum } from 'class-validator' import { Expose, Type } from 'class-transformer' +import { Equals, IsArray, ValidateNested, IsString, IsEnum } from 'class-validator' +import type { Verkey } from 'indy-sdk' import { AgentMessage } from '../../../agent/AgentMessage' + import { RoutingMessageType as MessageType } from './RoutingMessageType' export interface KeylistUpdateMessageOptions { diff --git a/src/modules/routing/messages/KeylistUpdateResponseMessage.ts b/src/modules/routing/messages/KeylistUpdateResponseMessage.ts index dafbd03257..aeb6b87239 100644 --- a/src/modules/routing/messages/KeylistUpdateResponseMessage.ts +++ b/src/modules/routing/messages/KeylistUpdateResponseMessage.ts @@ -1,10 +1,11 @@ -import type { Verkey } from 'indy-sdk' -import { Equals, IsArray, ValidateNested, IsString, IsEnum } from 'class-validator' import { Expose, Type } from 'class-transformer' +import { Equals, IsArray, ValidateNested, IsString, IsEnum } from 'class-validator' +import type { Verkey } from 'indy-sdk' import { AgentMessage } from '../../../agent/AgentMessage' -import { RoutingMessageType as MessageType } from './RoutingMessageType' + import { KeylistUpdateAction } from './KeylistUpdateMessage' +import { RoutingMessageType as MessageType } from './RoutingMessageType' export interface KeylistUpdateResponseMessageOptions { id?: string diff --git a/src/modules/routing/repository/ProvisioningRecord.ts b/src/modules/routing/repository/ProvisioningRecord.ts index 8680974f00..0902b54f22 100644 --- a/src/modules/routing/repository/ProvisioningRecord.ts +++ b/src/modules/routing/repository/ProvisioningRecord.ts @@ -1,5 +1,5 @@ -import { uuid } from '../../../utils/uuid' import { BaseRecord } from '../../../storage/BaseRecord' +import { uuid } from '../../../utils/uuid' interface ProvisioningRecordProps { id: string diff --git a/src/modules/routing/repository/ProvisioningRepository.ts b/src/modules/routing/repository/ProvisioningRepository.ts index ff0c5523ef..7234375030 100644 --- a/src/modules/routing/repository/ProvisioningRepository.ts +++ b/src/modules/routing/repository/ProvisioningRepository.ts @@ -1,10 +1,11 @@ import { inject, scoped, Lifecycle } from 'tsyringe' import { Repository } from '../../../storage/Repository' -import { ProvisioningRecord } from './ProvisioningRecord' import { StorageService } from '../../../storage/StorageService' import { Symbols } from '../../../symbols' +import { ProvisioningRecord } from './ProvisioningRecord' + @scoped(Lifecycle.ContainerScoped) export class ProvisioningRepository extends Repository { public constructor(@inject(Symbols.StorageService) storageService: StorageService) { diff --git a/src/modules/routing/services/ConsumerRoutingService.ts b/src/modules/routing/services/ConsumerRoutingService.ts index 679a0a5a89..4f947a56d4 100644 --- a/src/modules/routing/services/ConsumerRoutingService.ts +++ b/src/modules/routing/services/ConsumerRoutingService.ts @@ -1,11 +1,11 @@ import type { Verkey } from 'indy-sdk' import { Lifecycle, scoped } from 'tsyringe' -import { createOutboundMessage } from '../../../agent/helpers' import { AgentConfig } from '../../../agent/AgentConfig' import { MessageSender } from '../../../agent/MessageSender' -import { KeylistUpdateMessage, KeylistUpdate, KeylistUpdateAction } from '../messages' +import { createOutboundMessage } from '../../../agent/helpers' import { Logger } from '../../../logger' +import { KeylistUpdateMessage, KeylistUpdate, KeylistUpdateAction } from '../messages' @scoped(Lifecycle.ContainerScoped) class ConsumerRoutingService { diff --git a/src/modules/routing/services/MessagePickupService.ts b/src/modules/routing/services/MessagePickupService.ts index 5061905497..a12fe1fc44 100644 --- a/src/modules/routing/services/MessagePickupService.ts +++ b/src/modules/routing/services/MessagePickupService.ts @@ -1,12 +1,12 @@ import { inject, scoped, Lifecycle } from 'tsyringe' -import { InboundConnection } from '../../../types' import { createOutboundMessage } from '../../../agent/helpers' +import { AriesFrameworkError } from '../../../error' import { MessageRepository } from '../../../storage/MessageRepository' +import { Symbols } from '../../../symbols' +import { InboundConnection } from '../../../types' import { ConnectionRecord } from '../../connections' import { BatchMessage, BatchMessageMessage, BatchPickupMessage } from '../messages' -import { Symbols } from '../../../symbols' -import { AriesFrameworkError } from '../../../error' @scoped(Lifecycle.ContainerScoped) export class MessagePickupService { diff --git a/src/modules/routing/services/ProviderRoutingService.ts b/src/modules/routing/services/ProviderRoutingService.ts index 970f3eac04..d436ded08c 100644 --- a/src/modules/routing/services/ProviderRoutingService.ts +++ b/src/modules/routing/services/ProviderRoutingService.ts @@ -1,9 +1,10 @@ -import { Lifecycle, scoped } from 'tsyringe' import type { Verkey } from 'indy-sdk' +import { Lifecycle, scoped } from 'tsyringe' -import { OutboundMessage } from '../../../types' import { createOutboundMessage } from '../../../agent/helpers' import { InboundMessageContext } from '../../../agent/models/InboundMessageContext' +import { AriesFrameworkError } from '../../../error' +import { OutboundMessage } from '../../../types' import { ConnectionRecord } from '../../connections' import { KeylistUpdateMessage, @@ -13,7 +14,6 @@ import { KeylistUpdateResponseMessage, KeylistUpdateResult, } from '../messages' -import { AriesFrameworkError } from '../../../error' export interface RoutingTable { [recipientKey: string]: ConnectionRecord | undefined diff --git a/src/modules/routing/services/ProvisioningService.ts b/src/modules/routing/services/ProvisioningService.ts index 25873641d1..8366075009 100644 --- a/src/modules/routing/services/ProvisioningService.ts +++ b/src/modules/routing/services/ProvisioningService.ts @@ -1,11 +1,11 @@ import type { Verkey } from 'indy-sdk' import { inject, scoped, Lifecycle } from 'tsyringe' -import { ProvisioningRecord } from '../repository/ProvisioningRecord' -import { ProvisioningRepository } from '../repository' -import { Symbols } from '../../../symbols' -import { Logger } from '../../../logger' import { RecordNotFoundError } from '../../../error' +import { Logger } from '../../../logger' +import { Symbols } from '../../../symbols' +import { ProvisioningRepository } from '../repository' +import { ProvisioningRecord } from '../repository/ProvisioningRecord' const UNIQUE_PROVISIONING_ID = 'UNIQUE_PROVISIONING_ID' diff --git a/src/storage/InMemoryMessageRepository.ts b/src/storage/InMemoryMessageRepository.ts index 263e67ebda..11136a151f 100644 --- a/src/storage/InMemoryMessageRepository.ts +++ b/src/storage/InMemoryMessageRepository.ts @@ -1,9 +1,10 @@ -import { Lifecycle, scoped } from 'tsyringe' import type { Verkey } from 'indy-sdk' +import { Lifecycle, scoped } from 'tsyringe' -import { MessageRepository } from './MessageRepository' import { WireMessage } from '../types' +import { MessageRepository } from './MessageRepository' + @scoped(Lifecycle.ContainerScoped) export class InMemoryMessageRepository implements MessageRepository { private messages: { [key: string]: WireMessage } = {} diff --git a/src/storage/IndyStorageService.ts b/src/storage/IndyStorageService.ts index 128cd63efc..543d3a22d4 100644 --- a/src/storage/IndyStorageService.ts +++ b/src/storage/IndyStorageService.ts @@ -1,14 +1,14 @@ -import { inject, scoped, Lifecycle } from 'tsyringe' import type { WalletQuery, WalletRecord } from 'indy-sdk' +import { inject, scoped, Lifecycle } from 'tsyringe' -import { StorageService, BaseRecordConstructor } from './StorageService' -import { BaseRecord } from './BaseRecord' -import { Wallet } from '../wallet/Wallet' -import { JsonTransformer } from '../utils/JsonTransformer' +import { RecordNotFoundError, RecordDuplicateError } from '../error' import { Symbols } from '../symbols' - +import { JsonTransformer } from '../utils/JsonTransformer' import { handleIndyError, isIndyError } from '../utils/indyError' -import { RecordNotFoundError, RecordDuplicateError } from '../error' +import { Wallet } from '../wallet/Wallet' + +import { BaseRecord } from './BaseRecord' +import { StorageService, BaseRecordConstructor } from './StorageService' @scoped(Lifecycle.ContainerScoped) export class IndyStorageService implements StorageService { diff --git a/src/storage/MessageRepository.ts b/src/storage/MessageRepository.ts index bdea7bbdf9..7486607e4d 100644 --- a/src/storage/MessageRepository.ts +++ b/src/storage/MessageRepository.ts @@ -1,4 +1,5 @@ import type { Verkey } from 'indy-sdk' + import { WireMessage } from '../types' export interface MessageRepository { diff --git a/src/storage/Repository.ts b/src/storage/Repository.ts index 559b095621..059cb288c3 100644 --- a/src/storage/Repository.ts +++ b/src/storage/Repository.ts @@ -1,4 +1,5 @@ import type { WalletQuery } from 'indy-sdk' + import { RecordDuplicateError, RecordNotFoundError } from '../error' import { BaseRecord } from './BaseRecord' diff --git a/src/storage/StorageService.ts b/src/storage/StorageService.ts index b0308e5fbb..5b3b90a2ae 100644 --- a/src/storage/StorageService.ts +++ b/src/storage/StorageService.ts @@ -1,6 +1,7 @@ import type { WalletQuery } from 'indy-sdk' import { Constructor } from '../utils/mixins' + import { BaseRecord } from './BaseRecord' export interface BaseRecordConstructor extends Constructor { diff --git a/src/storage/__tests__/IndyStorageService.test.ts b/src/storage/__tests__/IndyStorageService.test.ts index 2f1102e111..ca2c6e0f8a 100644 --- a/src/storage/__tests__/IndyStorageService.test.ts +++ b/src/storage/__tests__/IndyStorageService.test.ts @@ -1,8 +1,9 @@ -import { IndyStorageService } from '../IndyStorageService' -import { IndyWallet } from '../../wallet/IndyWallet' -import { AgentConfig } from '../../agent/AgentConfig' import { getBaseConfig } from '../../__tests__/helpers' +import { AgentConfig } from '../../agent/AgentConfig' import { RecordDuplicateError, RecordNotFoundError } from '../../error' +import { IndyWallet } from '../../wallet/IndyWallet' +import { IndyStorageService } from '../IndyStorageService' + import { TestRecord } from './TestRecord' describe('IndyStorageService', () => { diff --git a/src/storage/__tests__/Repository.test.ts b/src/storage/__tests__/Repository.test.ts index da0b502c6f..b2175c8218 100644 --- a/src/storage/__tests__/Repository.test.ts +++ b/src/storage/__tests__/Repository.test.ts @@ -1,8 +1,9 @@ +import { mockFunction } from '../../__tests__/helpers' +import { AriesFrameworkError, RecordDuplicateError, RecordNotFoundError } from '../../error' +import { IndyStorageService } from '../IndyStorageService' import { Repository } from '../Repository' + import { TestRecord } from './TestRecord' -import { IndyStorageService } from '../IndyStorageService' -import { AriesFrameworkError, RecordDuplicateError, RecordNotFoundError } from '../../error' -import { mockFunction } from '../../__tests__/helpers' jest.mock('../IndyStorageService') diff --git a/src/storage/fs/NodeFileSystem.ts b/src/storage/fs/NodeFileSystem.ts index a5d410676b..a81dbe2812 100644 --- a/src/storage/fs/NodeFileSystem.ts +++ b/src/storage/fs/NodeFileSystem.ts @@ -1,6 +1,7 @@ import { promises } from 'fs' -import { dirname } from 'path' import { tmpdir } from 'os' +import { dirname } from 'path' + import { FileSystem } from './FileSystem' const { access, readFile, writeFile } = promises diff --git a/src/storage/fs/ReactNativeFileSystem.ts b/src/storage/fs/ReactNativeFileSystem.ts index af584d6f45..08f3c64b48 100644 --- a/src/storage/fs/ReactNativeFileSystem.ts +++ b/src/storage/fs/ReactNativeFileSystem.ts @@ -1,4 +1,5 @@ import RNFS from 'react-native-fs' + import { getDirFromFilePath } from '../../utils/path' import { FileSystem } from './FileSystem' diff --git a/src/transport/HttpOutboundTransporter.ts b/src/transport/HttpOutboundTransporter.ts index 01232f47c6..18413775d8 100644 --- a/src/transport/HttpOutboundTransporter.ts +++ b/src/transport/HttpOutboundTransporter.ts @@ -1,10 +1,11 @@ -import { OutboundTransporter } from './OutboundTransporter' import { Agent } from '../agent/Agent' +import { AgentConfig } from '../agent/AgentConfig' import { Logger } from '../logger' +import { Symbols } from '../symbols' import { OutboundPackage } from '../types' import { fetch } from '../utils/fetch' -import { Symbols } from '../symbols' -import { AgentConfig } from '../agent/AgentConfig' + +import { OutboundTransporter } from './OutboundTransporter' export class HttpOutboundTransporter implements OutboundTransporter { private agent: Agent diff --git a/src/transport/OutboundTransporter.ts b/src/transport/OutboundTransporter.ts index 15e4363f77..4e90d47566 100644 --- a/src/transport/OutboundTransporter.ts +++ b/src/transport/OutboundTransporter.ts @@ -3,6 +3,7 @@ import { OutboundPackage } from '../types' export interface OutboundTransporter { supportedSchemes: string[] + // eslint-disable-next-line @typescript-eslint/no-explicit-any sendMessage(outboundPackage: OutboundPackage): Promise start(): Promise diff --git a/src/transport/WsOutboundTransporter.ts b/src/transport/WsOutboundTransporter.ts index 35d2f5c5d9..274ae43952 100644 --- a/src/transport/WsOutboundTransporter.ts +++ b/src/transport/WsOutboundTransporter.ts @@ -1,12 +1,13 @@ -import { OutboundTransporter } from './OutboundTransporter' import { Agent } from '../agent/Agent' import { TransportSession } from '../agent/TransportService' import { Logger } from '../logger' import { ConnectionRecord } from '../modules/connections' -import { OutboundPackage } from '../types' import { Symbols } from '../symbols' +import { OutboundPackage } from '../types' import { WebSocket } from '../utils/ws' +import { OutboundTransporter } from './OutboundTransporter' + export class WebSocketTransportSession implements TransportSession { public readonly type = 'websocket' public socket?: WebSocket @@ -76,6 +77,7 @@ export class WsOutboundTransporter implements OutboundTransporter { // NOTE: Because this method is passed to the event handler this must be a lambda method // so 'this' is scoped to the 'WsOutboundTransporter' class instance + // eslint-disable-next-line @typescript-eslint/no-explicit-any private handleMessageEvent = (event: any) => { this.logger.debug('WebSocket message event received.', { url: event.target.url, data: event.data }) this.agent.receiveMessage(JSON.parse(event.data)) diff --git a/src/types.ts b/src/types.ts index f279d0be22..3480e013b1 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,11 +1,12 @@ -import type Indy from 'indy-sdk' -import type { WalletConfig, WalletCredentials, Verkey } from 'indy-sdk' -import { ConnectionRecord } from './modules/connections' +import type { default as Indy, WalletConfig, WalletCredentials, Verkey } from 'indy-sdk' + import { AgentMessage } from './agent/AgentMessage' import { TransportSession } from './agent/TransportService' import { Logger } from './logger' +import { ConnectionRecord } from './modules/connections' import { FileSystem } from './storage/fs/FileSystem' +// eslint-disable-next-line @typescript-eslint/no-explicit-any type $FixMe = any export type WireMessage = $FixMe diff --git a/src/utils/HashlinkEncoder.ts b/src/utils/HashlinkEncoder.ts index 76678b6cc9..791fa7e8c5 100644 --- a/src/utils/HashlinkEncoder.ts +++ b/src/utils/HashlinkEncoder.ts @@ -1,9 +1,10 @@ import cbor from 'borc' import { sha256 } from 'js-sha256' + import { BufferEncoder } from './BufferEncoder' -import { Buffer } from './buffer' import { MultibaseEncoder, BaseName } from './MultibaseEncoder' import { MultihashEncoder } from './MultihashEncoder' +import { Buffer } from './buffer' type Metadata = { urls?: string[] diff --git a/src/utils/MultibaseEncoder.ts b/src/utils/MultibaseEncoder.ts index 27319f209c..3a459ae00c 100644 --- a/src/utils/MultibaseEncoder.ts +++ b/src/utils/MultibaseEncoder.ts @@ -1,6 +1,4 @@ import multibase from 'multibase' -// eslint-disable-next-line @typescript-eslint/no-unused-vars -import { Buffer } from './buffer' export type BaseName = multibase.BaseName diff --git a/src/utils/MultihashEncoder.ts b/src/utils/MultihashEncoder.ts index 68f1e99f21..451dc7b5ee 100644 --- a/src/utils/MultihashEncoder.ts +++ b/src/utils/MultihashEncoder.ts @@ -1,5 +1,4 @@ import multihash from 'multihashes' -import { Buffer } from './buffer' export class MultihashEncoder { /** diff --git a/src/utils/__tests__/HashlinkEncoder.test.ts b/src/utils/__tests__/HashlinkEncoder.test.ts index 5fb5f3bfe6..48bfe219c9 100644 --- a/src/utils/__tests__/HashlinkEncoder.test.ts +++ b/src/utils/__tests__/HashlinkEncoder.test.ts @@ -1,4 +1,5 @@ import { Buffer } from 'buffer' + import { HashlinkEncoder } from '../HashlinkEncoder' const validData = { diff --git a/src/utils/__tests__/MultibaseEncoder.test.ts b/src/utils/__tests__/MultibaseEncoder.test.ts index db83ad8c82..7c7ecc2e5e 100644 --- a/src/utils/__tests__/MultibaseEncoder.test.ts +++ b/src/utils/__tests__/MultibaseEncoder.test.ts @@ -1,6 +1,7 @@ -import { MultibaseEncoder } from '../MultibaseEncoder' import { Buffer } from 'buffer' + import { BufferEncoder } from '../BufferEncoder' +import { MultibaseEncoder } from '../MultibaseEncoder' const validData = Buffer.from('Hello World!') const validMultibase = 'zKWfinQuRQ3ekD1danFHqvKRg9koFp8vpokUeREEgjSyHwweeKDFaxVHi' diff --git a/src/utils/__tests__/MultihashEncoder.test.ts b/src/utils/__tests__/MultihashEncoder.test.ts index 876d5de822..f17aa573d7 100644 --- a/src/utils/__tests__/MultihashEncoder.test.ts +++ b/src/utils/__tests__/MultihashEncoder.test.ts @@ -1,6 +1,7 @@ -import { MultihashEncoder } from '../MultihashEncoder' import { Buffer } from 'buffer' + import { BufferEncoder } from '../BufferEncoder' +import { MultihashEncoder } from '../MultihashEncoder' const validData = Buffer.from('Hello World!') const validMultihash = new Uint8Array([18, 12, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]) diff --git a/src/utils/indyError.ts b/src/utils/indyError.ts index 56747eb7d1..38974d30f7 100644 --- a/src/utils/indyError.ts +++ b/src/utils/indyError.ts @@ -74,7 +74,10 @@ export function handleIndyError(error: IndyError) { }) } +// eslint-disable-next-line @typescript-eslint/no-explicit-any export function isIndyError(error: any, errorName?: IndyErrorValues): error is IndyError { + if (typeof error !== 'object' || error === null) return false + const indyError = error.name === 'IndyError' // if no specific indy error name is passed diff --git a/src/utils/transformers.ts b/src/utils/transformers.ts index 0f2e2d608b..f090f55b6d 100644 --- a/src/utils/transformers.ts +++ b/src/utils/transformers.ts @@ -1,4 +1,5 @@ import { Transform, TransformationType } from 'class-transformer' + import { JsonTransformer } from './JsonTransformer' /** @@ -10,6 +11,7 @@ import { JsonTransformer } from './JsonTransformer' * private services: Record; * } */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any export function RecordTransformer(Class: { new (...args: any[]): T }) { return Transform(({ value, type }) => { switch (type) { diff --git a/src/wallet/IndyWallet.ts b/src/wallet/IndyWallet.ts index a6ed283265..6fb9b2aa57 100644 --- a/src/wallet/IndyWallet.ts +++ b/src/wallet/IndyWallet.ts @@ -1,5 +1,5 @@ -import { Lifecycle, scoped } from 'tsyringe' import type { + default as Indy, Did, DidConfig, LedgerRequest, @@ -11,15 +11,16 @@ import type { WalletRecordOptions, WalletSearchOptions, } from 'indy-sdk' -import type Indy from 'indy-sdk' +import { Lifecycle, scoped } from 'tsyringe' +import { AgentConfig } from '../agent/AgentConfig' +import { AriesFrameworkError } from '../error' +import { Logger } from '../logger' import { UnpackedMessageContext } from '../types' +import { JsonEncoder } from '../utils/JsonEncoder' import { isIndyError } from '../utils/indyError' + import { Wallet, DidInfo } from './Wallet' -import { JsonEncoder } from '../utils/JsonEncoder' -import { AgentConfig } from '../agent/AgentConfig' -import { Logger } from '../logger' -import { AriesFrameworkError } from '../error' @scoped(Lifecycle.ContainerScoped) export class IndyWallet implements Wallet { diff --git a/src/wallet/Wallet.test.ts b/src/wallet/Wallet.test.ts index eb36b7293c..5bd9a0e2df 100644 --- a/src/wallet/Wallet.test.ts +++ b/src/wallet/Wallet.test.ts @@ -1,6 +1,7 @@ -import { IndyWallet } from './IndyWallet' -import { AgentConfig } from '../agent/AgentConfig' import { getBaseConfig } from '../__tests__/helpers' +import { AgentConfig } from '../agent/AgentConfig' + +import { IndyWallet } from './IndyWallet' describe('Wallet', () => { const wallet = new IndyWallet(new AgentConfig(getBaseConfig('WalletTest'))) diff --git a/src/wallet/Wallet.ts b/src/wallet/Wallet.ts index c6eab2eece..5dc4668044 100644 --- a/src/wallet/Wallet.ts +++ b/src/wallet/Wallet.ts @@ -8,6 +8,7 @@ import type { WalletSearchOptions, LedgerRequest, } from 'indy-sdk' + import { UnpackedMessageContext } from '../types' export interface Wallet { diff --git a/tests/__tests__/e2e-ws.test.ts b/tests/__tests__/e2e-ws.test.ts index 21163cb6c3..42ca2bc6c6 100644 --- a/tests/__tests__/e2e-ws.test.ts +++ b/tests/__tests__/e2e-ws.test.ts @@ -1,7 +1,7 @@ import { Agent, InboundTransporter, WsOutboundTransporter } from '../../src' -import { get } from '../http' import { getBaseConfig, waitForBasicMessage } from '../../src/__tests__/helpers' import testLogger from '../../src/__tests__/logger' +import { get } from '../http' const logger = testLogger diff --git a/tests/__tests__/e2e.test.ts b/tests/__tests__/e2e.test.ts index bc651cc476..72af1fe64b 100644 --- a/tests/__tests__/e2e.test.ts +++ b/tests/__tests__/e2e.test.ts @@ -1,7 +1,7 @@ import { Agent, AriesFrameworkError, HttpOutboundTransporter, InboundTransporter } from '../../src' -import { get } from '../http' import { getBaseConfig, sleep, waitForBasicMessage } from '../../src/__tests__/helpers' import logger from '../../src/__tests__/logger' +import { get } from '../http' const aliceConfig = getBaseConfig('E2E Alice', { mediatorUrl: 'http://localhost:3001' }) const bobConfig = getBaseConfig('E2E Bob', { mediatorUrl: 'http://localhost:3002' }) diff --git a/tests/config.ts b/tests/config.ts index 05adfc249a..95461accf7 100644 --- a/tests/config.ts +++ b/tests/config.ts @@ -1,9 +1,10 @@ -import indy from 'indy-sdk' import * as dotenv from 'dotenv' -import { InitConfig } from '../src/types' -import { NodeFileSystem } from '../src/storage/fs/NodeFileSystem' +import indy from 'indy-sdk' + import { TestLogger } from '../src/__tests__/logger' import { LogLevel } from '../src/logger' +import { NodeFileSystem } from '../src/storage/fs/NodeFileSystem' +import { InitConfig } from '../src/types' dotenv.config() const agentConfig: InitConfig = { diff --git a/tests/http.ts b/tests/http.ts index 05b38ba5ae..49e6aacdc2 100644 --- a/tests/http.ts +++ b/tests/http.ts @@ -1,4 +1,5 @@ import fetch, { BodyInit } from 'node-fetch' + import testLogger from '../src/__tests__/logger' export async function get(url: string) { diff --git a/tests/mediator-ws.ts b/tests/mediator-ws.ts index 812a5fdad2..ae3da074a0 100644 --- a/tests/mediator-ws.ts +++ b/tests/mediator-ws.ts @@ -1,12 +1,14 @@ -import express from 'express' -import WebSocket from 'ws' import cors from 'cors' +import express from 'express' import { v4 as uuid } from 'uuid' -import config from './config' +import WebSocket from 'ws' + import { Agent, InboundTransporter, WebSocketTransportSession, WsOutboundTransporter } from '../src' -import { DidCommMimeType } from '../src/types' -import { InMemoryMessageRepository } from '../src/storage/InMemoryMessageRepository' import testLogger from '../src/__tests__/logger' +import { InMemoryMessageRepository } from '../src/storage/InMemoryMessageRepository' +import { DidCommMimeType } from '../src/types' + +import config from './config' const logger = testLogger @@ -21,7 +23,7 @@ class WsInboundTransporter implements InboundTransporter { } public async start(agent: Agent) { - this.socketServer.on('connection', (socket: any, _: Express.Request, socketId: string) => { + this.socketServer.on('connection', (socket: WebSocket, _: Express.Request, socketId: string) => { logger.debug('Socket connected.') if (!this.socketIds[socketId]) { @@ -36,6 +38,7 @@ class WsInboundTransporter implements InboundTransporter { } private listenOnWebSocketMessages(agent: Agent, socket: WebSocket) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any socket.addEventListener('message', async (event: any) => { logger.debug('WebSocket message event received.', { url: event.target.url, data: event.data }) // @ts-expect-error Property 'dispatchEvent' is missing in type WebSocket imported from 'ws' module but required in type 'WebSocket'. @@ -71,13 +74,13 @@ const messageReceiver = new WsInboundTransporter(socketServer) agent.setInboundTransporter(messageReceiver) agent.setOutboundTransporter(messageSender) -app.get('/', async (req, res) => { +app.get('/', async (_, res) => { const agentDid = agent.publicDid res.send(agentDid) }) // Create new invitation as inviter to invitee -app.get('/invitation', async (req, res) => { +app.get('/invitation', async (_, res) => { const { invitation } = await agent.connections.createConnection() res.send(invitation.toUrl()) @@ -102,11 +105,6 @@ app.get('/api/routes', async (req, res) => { res.send(routes) }) -app.get('/api/messages', async (req, res) => { - // TODO This endpoint is for testing purpose only. - // res.send(messageSender.messages) -}) - const server = app.listen(PORT, async () => { await agent.init() messageReceiver.start(agent) diff --git a/tests/mediator.ts b/tests/mediator.ts index 7cd7470e78..24adfd0a6f 100644 --- a/tests/mediator.ts +++ b/tests/mediator.ts @@ -1,11 +1,13 @@ -import express, { Express } from 'express' import cors from 'cors' -import config from './config' -import testLogger from '../src/__tests__/logger' +import express, { Express } from 'express' + import { Agent, AriesFrameworkError, InboundTransporter, OutboundTransporter } from '../src' -import { OutboundPackage, DidCommMimeType } from '../src/types' -import { MessageRepository } from '../src/storage/MessageRepository' +import testLogger from '../src/__tests__/logger' import { InMemoryMessageRepository } from '../src/storage/InMemoryMessageRepository' +import { MessageRepository } from '../src/storage/MessageRepository' +import { OutboundPackage, DidCommMimeType } from '../src/types' + +import config from './config' class HttpInboundTransporter implements InboundTransporter { private app: Express @@ -29,7 +31,6 @@ class HttpInboundTransporter implements InboundTransporter { } class StorageOutboundTransporter implements OutboundTransporter { - public messages: { [key: string]: any } = {} private messageRepository: MessageRepository public supportedSchemes = [] @@ -112,11 +113,6 @@ app.get('/api/routes', async (req, res) => { res.send(routes) }) -app.get('/api/messages', async (req, res) => { - // TODO This endpoint is for testing purpose only. - res.send(messageSender.messages) -}) - app.listen(PORT, async () => { await agent.init() messageReceiver.start(agent) diff --git a/types/jest.d.ts b/types/jest.d.ts index 5b3ca41dd1..4f68767c96 100644 --- a/types/jest.d.ts +++ b/types/jest.d.ts @@ -1,9 +1,8 @@ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -import { ConnectionRecord } from '../src/modules/connections/repository/ConnectionRecord' +import type { ConnectionRecord } from '../src/modules/connections/repository/ConnectionRecord' declare global { namespace jest { - interface Matchers { + interface Matchers { toBeConnectedWith(connection: ConnectionRecord): R } } diff --git a/yarn.lock b/yarn.lock index 548addc63c..dc570b0345 100644 --- a/yarn.lock +++ b/yarn.lock @@ -832,6 +832,11 @@ resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.7.tgz#98a993516c859eb0d5c4c8f098317a9ea68db9ad" integrity sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA== +"@types/json5@^0.0.29": + version "0.0.29" + resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" + integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4= + "@types/keyv@*": version "3.1.1" resolved "https://registry.yarnpkg.com/@types/keyv/-/keyv-3.1.1.tgz#e45a45324fca9dab716ab1230ee249c9fb52cfa7" @@ -1230,6 +1235,17 @@ array-flatten@1.1.1: resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" integrity sha1-ml9pkFGx5wczKPKgCJaLZOopVdI= +array-includes@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.1.3.tgz#c7f619b382ad2afaf5326cddfdc0afc61af7690a" + integrity sha512-gcem1KlBU7c9rB+Rq8/3PPKsK2kjqeEBa3bD5kkQo4nYlOHQCJqIJFqBXDEfwaRuYTT4E+FxA9xez7Gf/e3Q7A== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + es-abstract "^1.18.0-next.2" + get-intrinsic "^1.1.1" + is-string "^1.0.5" + array-union@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" @@ -1240,6 +1256,15 @@ array-unique@^0.3.2: resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" integrity sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg= +array.prototype.flat@^1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/array.prototype.flat/-/array.prototype.flat-1.2.4.tgz#6ef638b43312bd401b4c6199fdec7e2dc9e9a123" + integrity sha512-4470Xi3GAPAjZqFcljX2xzckv1qeKPizoNkiS0+O4IoPR2ZNpcjE0pkhdihlDouK+x6QOast26B4Q/O9DJnwSg== + dependencies: + call-bind "^1.0.0" + define-properties "^1.1.3" + es-abstract "^1.18.0-next.1" + assign-symbols@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" @@ -1998,7 +2023,7 @@ dateformat@~1.0.4-1.2.3: get-stdin "^4.0.1" meow "^3.3.0" -debug@2.6.9, debug@^2.2.0, debug@^2.3.3: +debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== @@ -2012,6 +2037,13 @@ debug@4, debug@4.3.1, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1: dependencies: ms "2.1.2" +debug@^3.2.7: + version "3.2.7" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" + integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== + dependencies: + ms "^2.1.1" + decamelize@^1.1.2, decamelize@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -2157,6 +2189,13 @@ dir-glob@^3.0.1: dependencies: path-type "^4.0.0" +doctrine@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d" + integrity sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw== + dependencies: + esutils "^2.0.2" + doctrine@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" @@ -2263,7 +2302,7 @@ error-ex@^1.2.0, error-ex@^1.3.1: dependencies: is-arrayish "^0.2.1" -es-abstract@^1.18.0-next.1, es-abstract@^1.18.0-next.2: +es-abstract@^1.18.0-next.1, es-abstract@^1.18.0-next.2, es-abstract@^1.18.2: version "1.18.3" resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.18.3.tgz#25c4c3380a27aa203c44b2b685bba94da31b63e0" integrity sha512-nQIr12dxV7SSxE6r6f1l3DtAeEYdsGpps13dR0TwJg1S8gyp4ZPgy3FZcHBgbiQqnoqSTb+oC+kO4UQ0C/J8vw== @@ -2341,6 +2380,43 @@ eslint-config-prettier@^8.1.0: resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.3.0.tgz#f7471b20b6fe8a9a9254cc684454202886a2dd7a" integrity sha512-BgZuLUSeKzvlL/VUjx/Yb787VQ26RU3gGjA3iiFvdsp/2bMfVIWUVP7tjxtjS0e+HP409cPlPvNkQloz8C91ew== +eslint-import-resolver-node@^0.3.4: + version "0.3.4" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.4.tgz#85ffa81942c25012d8231096ddf679c03042c717" + integrity sha512-ogtf+5AB/O+nM6DIeBUNr2fuT7ot9Qg/1harBfBtaP13ekEWFQEEMP94BCB7zaNW3gyY+8SHYF00rnqYwXKWOA== + dependencies: + debug "^2.6.9" + resolve "^1.13.1" + +eslint-module-utils@^2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.6.1.tgz#b51be1e473dd0de1c5ea638e22429c2490ea8233" + integrity sha512-ZXI9B8cxAJIH4nfkhTwcRTEAnrVfobYqwjWy/QMCZ8rHkZHFjf9yO4BzpiF9kCSfNlMG54eKigISHpX0+AaT4A== + dependencies: + debug "^3.2.7" + pkg-dir "^2.0.0" + +eslint-plugin-import@^2.23.4: + version "2.23.4" + resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.23.4.tgz#8dceb1ed6b73e46e50ec9a5bb2411b645e7d3d97" + integrity sha512-6/wP8zZRsnQFiR3iaPFgh5ImVRM1WN5NUWfTIRqwOdeiGJlBcSk82o1FEVq8yXmy4lkIzTo7YhHCIxlU/2HyEQ== + dependencies: + array-includes "^3.1.3" + array.prototype.flat "^1.2.4" + debug "^2.6.9" + doctrine "^2.1.0" + eslint-import-resolver-node "^0.3.4" + eslint-module-utils "^2.6.1" + find-up "^2.0.0" + has "^1.0.3" + is-core-module "^2.4.0" + minimatch "^3.0.4" + object.values "^1.1.3" + pkg-up "^2.0.0" + read-pkg-up "^3.0.0" + resolve "^1.20.0" + tsconfig-paths "^3.9.0" + eslint-plugin-prettier@^3.3.1: version "3.4.0" resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.4.0.tgz#cdbad3bf1dbd2b177e9825737fe63b476a08f0c7" @@ -2746,6 +2822,13 @@ find-up@^1.0.0: path-exists "^2.0.0" pinkie-promise "^2.0.0" +find-up@^2.0.0, find-up@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" + integrity sha1-RdG35QbHF93UgndaK3eSCjwMV6c= + dependencies: + locate-path "^2.0.0" + find-up@^4.0.0, find-up@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" @@ -3413,7 +3496,7 @@ is-ci@^2.0.0: dependencies: ci-info "^2.0.0" -is-core-module@^2.2.0: +is-core-module@^2.2.0, is-core-module@^2.4.0: version "2.4.0" resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.4.0.tgz#8e9fc8e15027b011418026e98f0e6f4d86305cc1" integrity sha512-6A2fkfq1rfeQZjxrZJGerpLCTHRNEBiSgnu0+obeJpEPZRUooHgsizvzv0ZjJwOz3iWIHdJtVWJ/tmPr3D21/A== @@ -4216,6 +4299,13 @@ json5@2.x, json5@^2.1.2: dependencies: minimist "^1.2.5" +json5@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe" + integrity sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow== + dependencies: + minimist "^1.2.0" + keyv@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/keyv/-/keyv-3.1.0.tgz#ecc228486f69991e49e9476485a5be1e8fc5c4d9" @@ -4318,6 +4408,14 @@ load-json-file@^4.0.0: pify "^3.0.0" strip-bom "^3.0.0" +locate-path@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" + integrity sha1-K1aLJl7slExtnA3pw9u7ygNUzY4= + dependencies: + p-locate "^2.0.0" + path-exists "^3.0.0" + locate-path@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" @@ -4658,7 +4756,7 @@ ms@2.1.2: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -ms@^2.0.0: +ms@^2.0.0, ms@^2.1.1: version "2.1.3" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== @@ -4913,6 +5011,15 @@ object.pick@^1.3.0: dependencies: isobject "^3.0.1" +object.values@^1.1.3: + version "1.1.4" + resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.1.4.tgz#0d273762833e816b693a637d30073e7051535b30" + integrity sha512-TnGo7j4XSnKQoK3MfvkzqKCi0nVe/D9I9IjwTNYdb/fxYHpjrluHVOgw0AF6jrRFGMPHdfuidR09tIDiIvnaSg== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + es-abstract "^1.18.2" + on-finished@~2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" @@ -5006,6 +5113,13 @@ p-finally@^1.0.0: resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" integrity sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4= +p-limit@^1.1.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8" + integrity sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q== + dependencies: + p-try "^1.0.0" + p-limit@^2.2.0: version "2.3.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" @@ -5020,6 +5134,13 @@ p-limit@^3.0.2: dependencies: yocto-queue "^0.1.0" +p-locate@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43" + integrity sha1-IKAQOyIqcMj9OcwuWAaA893l7EM= + dependencies: + p-limit "^1.1.0" + p-locate@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" @@ -5041,6 +5162,11 @@ p-map@^4.0.0: dependencies: aggregate-error "^3.0.0" +p-try@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" + integrity sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M= + p-try@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" @@ -5130,6 +5256,11 @@ path-exists@^2.0.0: dependencies: pinkie-promise "^2.0.0" +path-exists@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" + integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU= + path-exists@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" @@ -5220,6 +5351,13 @@ pirates@^4.0.1: dependencies: node-modules-regexp "^1.0.0" +pkg-dir@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-2.0.0.tgz#f6d5d1109e19d63edf428e0bd57e12777615334b" + integrity sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s= + dependencies: + find-up "^2.1.0" + pkg-dir@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" @@ -5227,6 +5365,13 @@ pkg-dir@^4.2.0: dependencies: find-up "^4.0.0" +pkg-up@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/pkg-up/-/pkg-up-2.0.0.tgz#c819ac728059a461cab1c3889a2be3c49a004d7f" + integrity sha1-yBmscoBZpGHKscOImivjxJoATX8= + dependencies: + find-up "^2.1.0" + posix-character-classes@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" @@ -5416,6 +5561,14 @@ read-pkg-up@^1.0.1: find-up "^1.0.0" read-pkg "^1.0.0" +read-pkg-up@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-3.0.0.tgz#3ed496685dba0f8fe118d0691dc51f4a1ff96f07" + integrity sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc= + dependencies: + find-up "^2.0.0" + read-pkg "^3.0.0" + read-pkg-up@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-7.0.1.tgz#f3a6135758459733ae2b95638056e1854e7ef507" @@ -5627,7 +5780,7 @@ resolve-url@^0.2.1: resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= -resolve@^1.0.0, resolve@^1.1.6, resolve@^1.10.0, resolve@^1.18.1: +resolve@^1.0.0, resolve@^1.1.6, resolve@^1.10.0, resolve@^1.13.1, resolve@^1.18.1, resolve@^1.20.0: version "1.20.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975" integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A== @@ -6436,6 +6589,16 @@ ts-node@^9.0.0: source-map-support "^0.5.17" yn "3.1.1" +tsconfig-paths@^3.9.0: + version "3.9.0" + resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.9.0.tgz#098547a6c4448807e8fcb8eae081064ee9a3c90b" + integrity sha512-dRcuzokWhajtZWkQsDVKbWyY+jgcLC5sqJhg2PSgf4ZkH2aHPvaOY8YWGhmjb68b5qqTfasSsDO9k7RUiEmZAw== + dependencies: + "@types/json5" "^0.0.29" + json5 "^1.0.1" + minimist "^1.2.0" + strip-bom "^3.0.0" + tsconfig@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/tsconfig/-/tsconfig-7.0.0.tgz#84538875a4dc216e5c4a5432b3a4dec3d54e91b7"