Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP #135

Draft
wants to merge 8 commits into
base: nanderstabel/issue119
Choose a base branch
from
Draft

WIP #135

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ rust-version = "1.76.0"

[workspace.dependencies]
did_manager = { git = "https://git@github.com/impierce/did-manager.git", tag = "v1.0.0-beta.3" }
siopv2 = { git = "https://git@github.com/impierce/openid4vc.git", rev = "12fed14" }
oid4vci = { git = "https://git@github.com/impierce/openid4vc.git", rev = "12fed14" }
oid4vc-core = { git = "https://git@github.com/impierce/openid4vc.git", rev = "12fed14" }
oid4vc-manager = { git = "https://git@github.com/impierce/openid4vc.git", rev = "12fed14" }
oid4vp = { git = "https://git@github.com/impierce/openid4vc.git", rev = "12fed14" }
siopv2 = { git = "https://git@github.com/impierce/openid4vc.git", rev = "b4b7a56" }
oid4vci = { git = "https://git@github.com/impierce/openid4vc.git", rev = "b4b7a56" }
oid4vc-core = { git = "https://git@github.com/impierce/openid4vc.git", rev = "b4b7a56" }
oid4vc-manager = { git = "https://git@github.com/impierce/openid4vc.git", rev = "b4b7a56" }
oid4vp = { git = "https://git@github.com/impierce/openid4vc.git", rev = "b4b7a56" }
# siopv2 = { path = "../openid4vc/siopv2" }
# oid4vci = { path = "../openid4vc/oid4vci"}
# oid4vc-core = { path = "../openid4vc/oid4vc-core"}
# oid4vc-manager = { path = "../openid4vc/oid4vc-manager" }
# oid4vp = { path = "../openid4vc/oid4vp" }

async-trait = "0.1"
axum = { version = "0.7", features = ["tracing"] }
Expand Down
178 changes: 144 additions & 34 deletions agent_api_rest/postman/ssi-agent.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -800,13 +800,18 @@
"exec": [
"const jsonData = JSON.parse(responseBody);",
"",
"if (jsonData && typeof jsonData === 'object') {",
" const receivedOfferId = Object.keys(jsonData)[0];",
"if (Array.isArray(jsonData) && jsonData.length > 0) {",
" const firstItem = jsonData[0];",
"",
" if (receivedOfferId) {",
" pm.collectionVariables.set(\"RECEIVED_OFFER_ID\", receivedOfferId);",
" if (firstItem && typeof firstItem === 'object') {",
" const receivedOfferId = firstItem.received_offer_id;",
"",
" if (receivedOfferId) {",
" pm.collectionVariables.set(\"RECEIVED_OFFER_ID\", receivedOfferId);",
" }",
" }",
"}"
"}",
""
],
"type": "text/javascript",
"packages": {}
Expand Down Expand Up @@ -911,13 +916,18 @@
"exec": [
"const jsonData = JSON.parse(responseBody);",
"",
"if (jsonData && typeof jsonData === 'object') {",
" const holderCredentialId = Object.keys(jsonData)[0];",
"if (Array.isArray(jsonData) && jsonData.length > 0) {",
" const firstItem = jsonData[0];",
"",
" if (holderCredentialId) {",
" pm.collectionVariables.set(\"HOLDER_CREDENTIAL_ID\", holderCredentialId);",
" if (firstItem && typeof firstItem === 'object') {",
" const holderCredentialId = firstItem.holder_credential_id;",
"",
" if (holderCredentialId) {",
" pm.collectionVariables.set(\"HOLDER_CREDENTIAL_ID\", holderCredentialId);",
" }",
" }",
"}"
"}",
""
],
"type": "text/javascript",
"packages": {}
Expand All @@ -926,8 +936,11 @@
{
"listen": "prerequest",
"script": {
"exec": [],
"type": "text/javascript"
"exec": [
""
],
"type": "text/javascript",
"packages": {}
}
}
],
Expand Down Expand Up @@ -977,13 +990,18 @@
"exec": [
"const jsonData = JSON.parse(responseBody);",
"",
"if (jsonData && typeof jsonData === 'object') {",
" const presentationId = Object.keys(jsonData)[0];",
"if (Array.isArray(jsonData) && jsonData.length > 0) {",
" const firstItem = jsonData[0];",
"",
" if (firstItem && typeof firstItem === 'object') {",
" const presentationId = firstItem.presentation_id;",
"",
" if (presentationId) {",
" pm.collectionVariables.set(\"PRESENTATION_ID\", presentationId);",
" if (presentationId) {",
" pm.collectionVariables.set(\"PRESENTATION_ID\", presentationId);",
" }",
" }",
"}"
"}",
""
],
"type": "text/javascript",
"packages": {}
Expand All @@ -992,8 +1010,11 @@
{
"listen": "prerequest",
"script": {
"exec": [],
"type": "text/javascript"
"exec": [
""
],
"type": "text/javascript",
"packages": {}
}
}
],
Expand Down Expand Up @@ -1125,13 +1146,18 @@
"exec": [
"const jsonData = JSON.parse(responseBody);",
"",
"if (jsonData && typeof jsonData === 'object') {",
" const connectionId = Object.keys(jsonData)[0];",
"if (Array.isArray(jsonData) && jsonData.length > 0) {",
" const firstItem = jsonData[0];",
"",
" if (connectionId) {",
" pm.collectionVariables.set(\"CONNECTION_ID\", connectionId);",
" if (firstItem && typeof firstItem === 'object') {",
" const connectionId = firstItem.connection_id;",
"",
" if (connectionId) {",
" pm.collectionVariables.set(\"CONNECTION_ID\", connectionId);",
" }",
" }",
"}"
"}",
""
],
"type": "text/javascript",
"packages": {}
Expand Down Expand Up @@ -1173,13 +1199,18 @@
"exec": [
"const jsonData = JSON.parse(responseBody);",
"",
"if (jsonData && typeof jsonData === 'object') {",
" const connectionId = Object.keys(jsonData)[0];",
"if (Array.isArray(jsonData) && jsonData.length > 0) {",
" const firstItem = jsonData[0];",
"",
" if (connectionId) {",
" pm.collectionVariables.set(\"CONNECTION_ID\", connectionId);",
" if (firstItem && typeof firstItem === 'object') {",
" const connectionId = firstItem.connection_id;",
"",
" if (connectionId) {",
" pm.collectionVariables.set(\"CONNECTION_ID\", connectionId);",
" }",
" }",
"}"
"}",
""
],
"type": "text/javascript",
"packages": {}
Expand Down Expand Up @@ -1227,13 +1258,18 @@
"exec": [
"const jsonData = JSON.parse(responseBody);",
"",
"if (jsonData && typeof jsonData === 'object') {",
" const connectionId = Object.keys(jsonData)[0];",
"if (Array.isArray(jsonData) && jsonData.length > 0) {",
" const firstItem = jsonData[0];",
"",
" if (connectionId) {",
" pm.collectionVariables.set(\"CONNECTION_ID\", connectionId);",
" if (firstItem && typeof firstItem === 'object') {",
" const connectionId = firstItem.connection_id;",
"",
" if (connectionId) {",
" pm.collectionVariables.set(\"CONNECTION_ID\", connectionId);",
" }",
" }",
"}"
"}",
""
],
"type": "text/javascript",
"packages": {}
Expand Down Expand Up @@ -1356,6 +1392,38 @@
},
{
"name": "services",
"event": [
{
"listen": "test",
"script": {
"exec": [
"const jsonData = JSON.parse(responseBody);",
"",
"if (Array.isArray(jsonData) && jsonData.length > 0) {",
" const firstItem = jsonData[0];",
"",
" if (firstItem && typeof firstItem === 'object') {",
" const serviceId = firstItem.service_id;",
"",
" if (serviceId) {",
" pm.collectionVariables.set(\"SERVICE_ID\", serviceId);",
" }",
" }",
"}",
""
],
"type": "text/javascript",
"packages": {}
}
},
{
"listen": "prerequest",
"script": {
"exec": [],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
Expand All @@ -1371,6 +1439,44 @@
}
},
"response": []
},
{
"name": "Service by ID",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{HOST}}/v0/services/{{SERVICE_ID}}",
"host": [
"{{HOST}}"
],
"path": [
"v0",
"services",
"{{SERVICE_ID}}"
]
}
},
"response": []
},
{
"name": "Linked Verifiable Presentation Service",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{HOST}}/v0/services/linked-verifiable-presentation-service",
"host": [
"{{HOST}}"
],
"path": [
"v0",
"services",
"linked-verifiable-presentation-service"
]
}
},
"response": []
}
]
}
Expand Down Expand Up @@ -1455,6 +1561,10 @@
"key": "CONNECTION_ID",
"value": "INITIAL_VALUE",
"type": "string"
},
{
"key": "SERVICE_ID",
"value": "INITIAL_VALUE"
}
]
}
12 changes: 10 additions & 2 deletions agent_api_rest/src/holder/holder/credentials/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@ use serde_json::json;
#[axum_macros::debug_handler]
pub(crate) async fn credentials(State(state): State<HolderState>) -> Response {
match query_handler("all_holder_credentials", &state.query.all_holder_credentials).await {
Ok(Some(all_credentials_view)) => (StatusCode::OK, Json(all_credentials_view)).into_response(),
Ok(None) => (StatusCode::OK, Json(json!({}))).into_response(),
Ok(Some(all_credentials_view)) => {
let all_credentials = all_credentials_view
.credentials
.into_iter()
.map(|(_, credential_view)| credential_view)
.collect::<Vec<_>>();

(StatusCode::OK, Json(all_credentials)).into_response()
}
Ok(None) => (StatusCode::OK, Json(json!([]))).into_response(),
_ => StatusCode::INTERNAL_SERVER_ERROR.into_response(),
}
}
Expand Down
Loading