Skip to content
Snippets Groups Projects
Commit e0065ca6 authored by Marvin Berstecher's avatar Marvin Berstecher Committed by Steffen Schulze
Browse files

Sprint 1 & 2: DIDComm Mediation Request

parent ae2bdcbe
No related branches found
No related tags found
No related merge requests found
Showing
with 332 additions and 58 deletions
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"
[build]
args_bin = []
bin = "./tmp/main"
cmd = "go build -o ./tmp/main ."
delay = 1000
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
post_cmd = []
pre_cmd = []
rerun = false
rerun_delay = 500
send_interrupt = false
stop_on_error = false
[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"
[log]
main_only = false
time = false
[misc]
clean_on_exit = false
[screen]
clear_on_rebuild = false
keep_scroll = true
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
didcommconnector
# Test binary, build with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
tmp/
# didcomm-rust lib is generated with make file
didcomm/lib/
[submodule "didcomm-rust"]
path = didcomm-rust
url = https://github.com/iBims1JFK/didcomm-rust
ignore = dirty
# DIDComm Connector
# DIDComm Connector WIP
## Description
The DIDCommConnector can be used as a Mediator and Connection Management Service by parties who want to set up trust with another party. The DIDCommConnector uses DIDComm v2 and provides a message layer and a management component for the following two use cases:
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
- Pairing a cloud solution with a smartphone / app solution
- DIDComm v2 based message protocols
```
cd existing_repo
git remote add origin https://gitlab.eclipse.org/eclipse/xfsc/common-services/didcomm-connector.git
git branch -M main
git push -uf origin main
```
## Badges
## Integrate with your tools
TODO: On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
- [ ] [Set up project integrations](https://gitlab.eclipse.org/eclipse/xfsc/common-services/didcomm-connector/-/settings/integrations)
## Visuals
## Collaborate with your team
TODO: Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Installation
## Test and Deploy
How to install:
Use the built-in continuous integration in GitLab.
- Execute `go get` in the main directory.
- To install all needed dependencies use the `makefile` and run `make`.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
For Development (Linux):
***
- Install air for `make install-air`
- Add `export $PATH=PATH:your/path/to/go/bin` to path (`~/.bashrc`)
# Editing this README
## Usage
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
The application is still under development.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
How to run the application:
## Name
Choose a self-explaining name for your project.
- To start the application execute `make dev`.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
### swagger
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
The swagger is available at the URL: `localhost:9090/swagger/index.html`
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
TODO: Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
TODO: If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
TODO: State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
TODO: Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
TODO: For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
The project is in an early phase of development. Therefore it cannot be used as it is now.
The API is not final.
package controller
import (
"fmt"
"net/http"
"net/url"
"github.com/gin-gonic/gin"
)
type ConnectionController struct{}
// PingExample godoc
// @Summary Create a new connection
// @Schemes
// @Description Creates connection endpoint (more to be added)
// @Tags Connections
// @Accept json
// @Produce json
// @Param did path string true "DID"
// @Success 201 {object} model.Connection
// @Router /connections/{did} [post]
func (cc ConnectionController) CreateConnectionEndpoint(context *gin.Context) {
context.Status(http.StatusNotImplemented)
}
// PingExample godoc
// @Summary Update existing connection
// @Schemes
// @Description Updates existing connection (more to be added)
// @Tags Connections
// @Accept json
// @Produce json
// @Param did body model.Connection true "DID"
// @Success 204 {string} string "Updated"
// @Router /connections [patch]
func (cc ConnectionController) UpdateConnection(context *gin.Context) {
did := context.Param("did")
fmt.Println("Given DID: " + did)
context.Status(http.StatusNotImplemented)
}
// PingExample godoc
// @Summary Delete connection
// @Schemes
// @Description Deletes connection (more to be added)
// @Tags Connections
// @Accept json
// @Produce json
// @Param did path string true "DID"
// @Success 204 {string} string "Deleted"
// @Router /connections/{did} [delete]
func (cc ConnectionController) DeleteConnection(context *gin.Context) {
did := context.Param("did")
fmt.Println("Given DID: " + did)
context.Status(http.StatusNotImplemented)
}
// PingExample godoc
// @Summary Get connection information
// @Schemes
// @Description Returns existing connection information (more to be added)
// @Tags Connections
// @Accept json
// @Produce json
// @Param did path string true "DID"
// @Success 200 {object} model.Connection
// @Router /connections/{did} [get]
func (cc ConnectionController) ConnectionInformation(context *gin.Context) {
did := context.Param("did")
did, err := url.QueryUnescape(did)
if err != nil {
context.Status(http.StatusBadRequest)
return
}
fmt.Println("Given DID:", did)
context.Status(http.StatusNotImplemented)
}
// PingExample godoc
// @Summary Get connections
// @Schemes
// @Description Returns a list with the existing connections (more to be added)
// @Tags Connections
// @Accept json
// @Produce json
// @Success 200 {array} model.Connection
// @Router /connections [get]
func (cc ConnectionController) ListConnections(context *gin.Context) {
context.Status(http.StatusNotImplemented)
}
// PingExample godoc
// @Summary Get connection status
// @Schemes
// @Description Returns connection status (more to be added)
// @Tags Connections
// @Accept json
// @Produce json
// @Param did path string true "DID"
// @Success 200 {object} model.ConnectionStatus
// @Router /connections/status/{did} [get]
func (cc ConnectionController) ConnectionStatus(context *gin.Context) {
did := context.Param("did")
fmt.Println("Given DID: " + did)
context.Status(http.StatusNotImplemented)
}
// PingExample godoc
// @Summary Block existing connection
// @Schemes
// @Description Blocks existing connection (more to be added)
// @Tags Connections
// @Accept json
// @Produce json
// @Param did path string true "DID"
// @Success 204 {string} string "Blocked"
// @Router /connections/block/{did} [post]
func (cc ConnectionController) BlockConnection(context *gin.Context) {
did := context.Param("did")
fmt.Println("Given DID: " + did)
context.Status(http.StatusNotImplemented)
}
package controller
type DidCommController struct{}
// TODO: add routes
package controller
import (
"net/http"
"github.com/gin-gonic/gin"
)
type HelloWorldController struct{}
func (h HelloWorldController) HelloWorld(context *gin.Context) {
context.String(http.StatusOK, "Hello World!")
}
package controller
import (
"encoding/json"
"fmt"
"gaiax/didcommconnector/protocol"
"gaiax/didcommconnector/utils"
"io"
"net/http"
"github.com/gin-gonic/gin"
)
type MessageController struct{}
// PingExample godoc
// @Summary TODO
// @Schemes TODO
// @Description TODO
// @Tags Message
// @Accept json
// @Produce json
// @Success 200 {string} test
// @Router /message [patch]
func (cc MessageController) ReceiveMessage(context *gin.Context) {
// dcomm := didcomm.CreateDidcommInstance()
// options := didcomm.UnpackOptions{
// ExpectDecryptByAllKeys: false,
// UnwrapReWrappingForward: false,
// }
// msgCh := make(chan didcomm.Message, 1)
// errCh := make(chan didcomm.UnpackErrorPair, 1)
// unpackCB := &didcomm.UnpackResultCallback{}
// unpackCB.New(msgCh, errCh)
// go dcomm.Unpack(bodyString, options, unpackCB)
// select {
// case err := <-errCh:
// fmt.Println("Error unpacking message:", err)
// context.String(http.StatusInternalServerError, "Error unpacking message")
// case message := <-msgCh:
// fmt.Println("Message received:", message.To)
// context.Status(http.StatusOK)
// }
body, err := io.ReadAll(context.Request.Body)
if err != nil {
context.String(500, "Error reading request body")
return
}
bodyString := string(body)
msg, err := utils.UnpackMessage(bodyString)
if err != nil {
fmt.Println("Error unpacking message:", err)
context.String(http.StatusInternalServerError, "Error unpacking message")
return
}
switch msg.Type {
case "https://didcomm.org/coordinate-mediation/3.0/mediate-request":
responseMsg, err := protocol.HandleCoordinateMediation(msg)
if err != nil {
context.String(http.StatusInternalServerError, "Error handling coordinate mediation")
return
}
packMsg, err := utils.PackPlainMessage(responseMsg, "did:example:mediator")
if err != nil {
context.String(http.StatusInternalServerError, "Error packing message")
return
} else {
var jsonMap map[string]interface{}
json.Unmarshal([]byte(packMsg), &jsonMap)
context.JSON(http.StatusOK, jsonMap)
}
default:
context.String(http.StatusBadRequest, "Unknown message type")
}
}
File added
File added
File added
2190465669
\ No newline at end of file
Filter.db
CompressionInfo.db
Summary.db
Index.db
Digest.crc32
TOC.txt
Data.db
Statistics.db
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment