From 6fd6375005c385c2640119667eb989de1a8a9374 Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Wed, 3 Jul 2024 14:07:46 +0200 Subject: [PATCH] http: Add ssh keys and full did to nodes handler --- radicle-httpd/src/api/v1/node.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/radicle-httpd/src/api/v1/node.rs b/radicle-httpd/src/api/v1/node.rs index 605ae2049..b1f7c8c39 100644 --- a/radicle-httpd/src/api/v1/node.rs +++ b/radicle-httpd/src/api/v1/node.rs @@ -4,7 +4,8 @@ use axum::routing::get; use axum::{Json, Router}; use serde_json::json; -use radicle::identity::RepoId; +use radicle::crypto::ssh::fmt; +use radicle::identity::{Did, RepoId}; use radicle::node::address::Store as AddressStore; use radicle::node::routing::Store; use radicle::node::{AliasStore, Handle, NodeId}; @@ -61,6 +62,11 @@ async fn nodes_handler(State(ctx): State, Path(nid): Path) -> i let aliases = ctx.profile.aliases(); let response = json!({ "alias": aliases.alias(&nid), + "did": Did::from(nid), + "ssh": { + "full": fmt::key(&nid), + "hash": fmt::fingerprint(&nid) + } }); Ok::<_, Error>(Json(response)) @@ -181,6 +187,11 @@ mod routes { response.json().await, json!({ "alias": "seed", + "did": "did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi", + "ssh": { + "full": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHahWSBEpuT1ESZbynOmBNkLBSnR32Ar4woZqSV2YNH1", + "hash": "SHA256:UIedaL6Cxm6OUErh9GQUzzglSk7VpQlVTI1TAFB/HWA", + }, }) ); }