From 64a5e9615bc8d5204e4f0a2bbf985b982e18f6b0 Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Fri, 24 Jul 2026 13:39:31 +0000 Subject: [PATCH] bobbin: add sh.tangled.publicKey.getPublicKey mimicing getIssue/getStar etc. Signed-off-by: oppiliappan --- flake.nix | 1 + lexicons/publicKey/getPublicKey.json | 41 +++++++++++++++++++++++++++++++++++++++++ bobbin/crates/xrpc/src/lib.rs | 25 ++++++++++++++++++++++++- 3 file(s) changed, 66 insertion(s)(+), 1 deletion(s)(-) diff --git a/flake.nix b/flake.nix --- a/flake.nix +++ b/flake.nix @@ -399,6 +399,7 @@ fenix.packages.${system}.stable.rust-src fenix.packages.${system}.stable.clippy fenix.packages.${system}.stable.rustfmt + fenix.packages.${system}.stable.rust-analyzer fenix.packages.${system}.targets.wasm32-unknown-unknown.stable.rust-std ]) pkgs.coreutils # for those of us who are on systems that use busybox (alpine) diff --git a/lexicons/publicKey/getPublicKey.json b/lexicons/publicKey/getPublicKey.json new file mode 100644 --- /dev/null +++ b/lexicons/publicKey/getPublicKey.json @@ -0,0 +1,41 @@ +{ + "lexicon": 1, + "id": "sh.tangled.publicKey.getPublicKey", + "defs": { + "main": { + "type": "query", + "parameters": { + "type": "params", + "required": ["publicKey"], + "properties": { + "publicKey": { + "type": "string", + "format": "at-uri", + "description": "AT-URI of the sh.tangled.publicKey record to fetch." + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["uri", "value"], + "properties": { + "uri": { + "type": "string", + "format": "at-uri" + }, + "cid": { + "type": "string", + "format": "cid" + }, + "value": { + "type": "unknown", + "description": "Embedded sh.tangled.publicKey record." + } + } + } + } + } + } +} diff --git a/bobbin/crates/xrpc/src/lib.rs b/bobbin/crates/xrpc/src/lib.rs --- a/bobbin/crates/xrpc/src/lib.rs +++ b/bobbin/crates/xrpc/src/lib.rs @@ -58,7 +58,7 @@ Status as PipelineStatus, StatusRecord as PipelineStatusRecord, }; use bobbin_types::sh_tangled::pipeline::{Pipeline, PipelineRecord}; -use bobbin_types::sh_tangled::public_key::{PublicKey, PublicKeyRecord}; +use bobbin_types::sh_tangled::public_key::{PublicKey, PublicKeyGetRecordOutput, PublicKeyRecord}; use bobbin_types::sh_tangled::repo::artifact::{Artifact, ArtifactRecord}; use bobbin_types::sh_tangled::repo::collaborator::{Collaborator, CollaboratorRecord}; use bobbin_types::sh_tangled::repo::issue::state::{ @@ -242,6 +242,10 @@ .route( "/xrpc/sh.tangled.spindle.countSpindles", get(count_spindles), + ) + .route( + "/xrpc/sh.tangled.publicKey.getPublicKey", + get(get_public_key), ) .route("/xrpc/sh.tangled.publicKey.listKeys", get(list_public_keys)) .route( @@ -613,6 +617,12 @@ #[derive(Debug, Deserialize)] struct GetPullQuery { pull: AtUri, +} + +#[derive(Debug, Deserialize)] +struct GetPublicKeyQuery { + #[serde(rename = "publicKey")] + public_key: AtUri, } #[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq)] @@ -1303,6 +1313,19 @@ ) -> Result>>, XrpcError> { let (body, value) = fetch::>(&state, &q.pull).await?; Ok(Json(Deduped(PullGetRecordOutput { + cid: Some(body.cid.clone()), + uri: body.uri.clone(), + value, + }))) +} + +async fn get_public_key( + State(state): State, + XrpcQuery(q): XrpcQuery, +) -> Result>>, XrpcError> { + let (body, value) = + fetch::>(&state, &q.public_key).await?; + Ok(Json(Deduped(PublicKeyGetRecordOutput { cid: Some(body.cid.clone()), uri: body.uri.clone(), value, -- tangled.sh