-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add problem report protocol (#560)
Signed-off-by: Amit Padmani <[email protected]>
- Loading branch information
Showing
46 changed files
with
1,075 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export enum CommonMessageType { | ||
Ack = 'https://didcomm.org/notification/1.0/ack', | ||
ProblemReport = 'https://didcomm.org/notification/1.0/problem-report', | ||
} |
22 changes: 22 additions & 0 deletions
22
packages/core/src/modules/connections/errors/ConnectionProblemReportError.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { ConnectionProblemReportReason } from '.' | ||
import type { ProblemReportErrorOptions } from '../../problem-reports' | ||
|
||
import { ProblemReportError } from '../../problem-reports' | ||
import { ConnectionProblemReportMessage } from '../messages' | ||
|
||
interface ConnectionProblemReportErrorOptions extends ProblemReportErrorOptions { | ||
problemCode: ConnectionProblemReportReason | ||
} | ||
export class ConnectionProblemReportError extends ProblemReportError { | ||
public problemReport: ConnectionProblemReportMessage | ||
|
||
public constructor(public message: string, { problemCode }: ConnectionProblemReportErrorOptions) { | ||
super(message, { problemCode }) | ||
this.problemReport = new ConnectionProblemReportMessage({ | ||
description: { | ||
en: message, | ||
code: problemCode, | ||
}, | ||
}) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/core/src/modules/connections/errors/ConnectionProblemReportReason.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Connection error code in RFC 160. | ||
* | ||
* @see https://github.com/hyperledger/aries-rfcs/blob/main/features/0160-connection-protocol/README.md#errors | ||
*/ | ||
export enum ConnectionProblemReportReason { | ||
RequestNotAccepted = 'request_not_accepted', | ||
RequestProcessingError = 'request_processing_error', | ||
ResponseNotAccepted = 'response_not_accepted', | ||
ResponseProcessingError = 'response_processing_error', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './ConnectionProblemReportError' | ||
export * from './ConnectionProblemReportReason' |
17 changes: 17 additions & 0 deletions
17
packages/core/src/modules/connections/handlers/ConnectionProblemReportHandler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { Handler, HandlerInboundMessage } from '../../../agent/Handler' | ||
import type { ConnectionService } from '../services' | ||
|
||
import { ConnectionProblemReportMessage } from '../messages' | ||
|
||
export class ConnectionProblemReportHandler implements Handler { | ||
private connectionService: ConnectionService | ||
public supportedMessages = [ConnectionProblemReportMessage] | ||
|
||
public constructor(connectionService: ConnectionService) { | ||
this.connectionService = connectionService | ||
} | ||
|
||
public async handle(messageContext: HandlerInboundMessage<ConnectionProblemReportHandler>) { | ||
await this.connectionService.processProblemReport(messageContext) | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/core/src/modules/connections/messages/ConnectionProblemReportMessage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { ProblemReportMessageOptions } from '../../problem-reports/messages/ProblemReportMessage' | ||
|
||
import { Equals } from 'class-validator' | ||
|
||
import { ProblemReportMessage } from '../../problem-reports/messages/ProblemReportMessage' | ||
|
||
export type ConnectionProblemReportMessageOptions = ProblemReportMessageOptions | ||
|
||
/** | ||
* @see https://github.com/hyperledger/aries-rfcs/blob/main/features/0035-report-problem/README.md | ||
*/ | ||
export class ConnectionProblemReportMessage extends ProblemReportMessage { | ||
/** | ||
* Create new ConnectionProblemReportMessage instance. | ||
* @param options | ||
*/ | ||
public constructor(options: ConnectionProblemReportMessageOptions) { | ||
super(options) | ||
} | ||
|
||
@Equals(ConnectionProblemReportMessage.type) | ||
public readonly type = ConnectionProblemReportMessage.type | ||
public static readonly type = 'https://didcomm.org/connection/1.0/problem-report' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.