Skip to content

Commit

Permalink
refactor: Extract ack message from connections to common module (open…
Browse files Browse the repository at this point in the history
…wallet-foundation#210)

Signed-off-by: Jakub Koci <[email protected]>
  • Loading branch information
jakubkoci authored Mar 18, 2021
1 parent ac7b377 commit 04a3e3f
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/lib/modules/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './messages/AckMessage';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Equals, IsEnum } from 'class-validator';

import { AgentMessage } from '../../../agent/AgentMessage';
import { ConnectionMessageType } from './ConnectionMessageType';
import { CommonMessageType } from './CommonMessageType';

/**
* Ack message status types
Expand Down Expand Up @@ -41,7 +41,7 @@ export class AckMessage extends AgentMessage {

@Equals(AckMessage.type)
public readonly type: string = AckMessage.type;
public static readonly type: string = ConnectionMessageType.Ack;
public static readonly type: string = CommonMessageType.Ack;

@IsEnum(AckStatus)
public status!: AckStatus;
Expand Down
3 changes: 3 additions & 0 deletions src/lib/modules/common/messages/CommonMessageType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export enum CommonMessageType {
Ack = 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/notification/1.0/ack',
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import {
ConnectionRequestMessage,
ConnectionResponseMessage,
TrustPingMessage,
AckMessage,
AckStatus,
} from '../messages';
import { AckMessage, AckStatus } from '../../common';
import { Repository } from '../../../storage/Repository';
import { signData, unpackAndVerifySignatureDecorator } from '../../../decorators/signature/SignatureDecoratorUtils';
import { InboundMessageContext } from '../../../agent/models/InboundMessageContext';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/modules/connections/handlers/AckMessageHandler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Handler, HandlerInboundMessage } from '../../../agent/Handler';
import { ConnectionService } from '../services/ConnectionService';
import { AckMessage } from '../messages';
import { AckMessage } from '../../common';

export class AckMessageHandler implements Handler {
private connectionService: ConnectionService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export enum ConnectionMessageType {
ConnectionInvitation = 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation',
ConnectionRequest = 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/request',
ConnectionResponse = 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/response',
Ack = 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/notification/1.0/ack',
TrustPingMessage = 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/trust_ping/1.0/ping',
TrustPingResponseMessage = 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/trust_ping/1.0/ping_response',
}
1 change: 0 additions & 1 deletion src/lib/modules/connections/messages/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './AckMessage';
export * from './ConnectionInvitationMessage';
export * from './ConnectionMessageType';
export * from './ConnectionRequestMessage';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/modules/connections/services/ConnectionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
ConnectionInvitationMessage,
ConnectionRequestMessage,
ConnectionResponseMessage,
AckMessage,
TrustPingMessage,
} from '../messages';
import { AckMessage } from '../../common';
import { signData, unpackAndVerifySignatureDecorator } from '../../../decorators/signature/SignatureDecoratorUtils';
import {
Connection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ 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 { LedgerService as LedgerServiceImpl } from '../../ledger/services';
import { ConnectionState } from '../../connections';
import { getMockConnection } from '../../connections/__tests__/ConnectionService.test';
import { AckStatus } from '../../connections';
import { AgentConfig } from '../../../agent/AgentConfig';

jest.mock('./../../../storage/Repository');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Equals } from 'class-validator';
import { IssueCredentialMessageType } from './IssueCredentialMessageType';

import { AckMessage, AckMessageOptions } from '../../../modules/connections';
import { AckMessage, AckMessageOptions } from '../../../modules/common';

export type CredentialAckMessageOptions = AckMessageOptions;

Expand Down
3 changes: 2 additions & 1 deletion src/lib/modules/credentials/services/CredentialService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AgentMessage } from '../../../agent/AgentMessage';
import { LedgerService } from '../../ledger/services/LedgerService';
import { InboundMessageContext } from '../../../agent/models/InboundMessageContext';
import { Attachment, AttachmentData } from '../../../decorators/attachment/Attachment';
import { ConnectionService, ConnectionRecord, AckStatus } from '../../connections';
import { ConnectionService, ConnectionRecord } from '../../connections';
import { CredentialRecord } from '../repository/CredentialRecord';
import { Repository } from '../../../storage/Repository';
import { JsonEncoder } from '../../../utils/JsonEncoder';
Expand All @@ -28,6 +28,7 @@ import {
ProposeCredentialMessage,
ProposeCredentialMessageOptions,
} from '../messages';
import { AckStatus } from '../../common';
import { Logger } from '../../../logger';
import { AgentConfig } from '../../../agent/AgentConfig';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/modules/proofs/messages/PresentationAckMessage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Equals } from 'class-validator';

import { AckMessage, AckMessageOptions } from '../../../modules/connections';
import { AckMessage, AckMessageOptions } from '../../../modules/common';
import { PresentProofMessageType } from './PresentProofMessageType';

export type PresentationAckMessageOptions = AckMessageOptions;
Expand Down
3 changes: 2 additions & 1 deletion src/lib/modules/proofs/services/ProofService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { AgentMessage } from '../../../agent/AgentMessage';
import { LedgerService } from '../../ledger/services/LedgerService';
import { InboundMessageContext } from '../../../agent/models/InboundMessageContext';
import { Attachment, AttachmentData } from '../../../decorators/attachment/Attachment';
import { ConnectionRecord, AckStatus } from '../../connections';
import { ConnectionRecord } from '../../connections';
import { ProofRecord } from '../repository/ProofRecord';
import { Repository } from '../../../storage/Repository';
import { JsonEncoder } from '../../../utils/JsonEncoder';
Expand All @@ -26,6 +26,7 @@ import {
INDY_PROOF_REQUEST_ATTACHMENT_ID,
INDY_PROOF_ATTACHMENT_ID,
} from '../messages';
import { AckStatus } from '../../common';
import {
PartialProof,
ProofAttributeInfo,
Expand Down

0 comments on commit 04a3e3f

Please sign in to comment.