-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: integrating error reporting protocol (#289)
Signed-off-by: Francisco Javier Ribo Labrador <elribonazo@gmail.com>
- Loading branch information
1 parent
f53d728
commit 02430db
Showing
11 changed files
with
169 additions
and
7 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
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { AgentError, DID, Message } from "../../../domain/models"; | ||
import { parseProblemReportBody } from "../../helpers/ProtocolHelpers"; | ||
import { ProtocolType } from "../ProtocolTypes"; | ||
import { ProblemReportBody } from "../types"; | ||
|
||
|
||
|
||
|
||
|
||
export class ProblemReport { | ||
public static type = ProtocolType.ProblemReporting; | ||
|
||
constructor( | ||
public body: ProblemReportBody, | ||
public from: DID, | ||
public to: DID, | ||
public thid?: string, | ||
) { } | ||
|
||
makeMessage(): Message { | ||
const body = JSON.stringify(this.body); | ||
return new Message( | ||
body, | ||
undefined, | ||
ProblemReport.type, | ||
this.from, | ||
this.to, | ||
[], | ||
this.thid | ||
); | ||
} | ||
|
||
static fromMessage(fromMessage: Message): ProblemReport { | ||
if ( | ||
fromMessage.piuri !== ProtocolType.DidcommBasicMessage || | ||
!fromMessage.from || | ||
!fromMessage.to | ||
) { | ||
throw new AgentError.InvalidBasicMessageBodyError( | ||
"Invalid BasicMessage body error." | ||
); | ||
} | ||
const problemReportBody = parseProblemReportBody(fromMessage); | ||
return new ProblemReport( | ||
problemReportBody, | ||
fromMessage.from, | ||
fromMessage.to | ||
); | ||
} | ||
} |
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
02430db
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.