Skip to content

Commit 973e66c

Browse files
Remove KV client functions from the SDKs
The OpenSecret KV endpoints are gone, so drop the matching client surface: the TypeScript fetchGet/fetchPut/fetchList/fetchDelete/ fetchDeleteAllKV helpers, KVListItem, and the get/put/list/del/delAll context members, plus the Rust kv_* methods and KVListItem. Remove the KV integration tests and the KV step of the Rust api_usage example. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent ff628d9 commit 973e66c

8 files changed

Lines changed: 14 additions & 409 deletions

File tree

‎sdk/rust/examples/api_usage.rs‎

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -59,33 +59,8 @@ async fn main() -> Result<()> {
5959
println!(" Created: {}", user.user.created_at);
6060
println!();
6161

62-
// Step 4: Key-Value Storage
63-
println!("4️⃣ Key-Value Storage");
64-
65-
// Store a value
66-
let key = "user_preference";
67-
let value = r#"{"theme": "dark", "language": "en"}"#;
68-
client.kv_put(key, value.to_string()).await?;
69-
println!(" ✓ Stored: {} = {}", key, value);
70-
71-
// Retrieve the value
72-
let retrieved = client.kv_get(key).await?;
73-
println!(" ✓ Retrieved: {}", retrieved);
74-
75-
// List all keys
76-
let keys = client.kv_list().await?;
77-
println!(" ✓ Total keys: {}", keys.len());
78-
for item in keys.iter().take(3) {
79-
println!(" - {}: {}", item.key, item.value);
80-
}
81-
82-
// Clean up
83-
client.kv_delete(key).await?;
84-
println!(" ✓ Deleted key: {}", key);
85-
println!();
86-
87-
// Step 5: Private Key Generation
88-
println!("5️⃣ Private Key Generation");
62+
// Step 4: Private Key Generation
63+
println!("4️⃣ Private Key Generation");
8964

9065
// Generate default mnemonic (12 words)
9166
let private_key = client.get_private_key(None).await?;
@@ -118,8 +93,8 @@ async fn main() -> Result<()> {
11893
);
11994
println!();
12095

121-
// Step 6: Message Signing
122-
println!("6️⃣ Digital Signatures");
96+
// Step 5: Message Signing
97+
println!("5️⃣ Digital Signatures");
12398
let message = "Sign this important message";
12499

125100
// Sign with Schnorr (Bitcoin Taproot compatible)
@@ -157,8 +132,8 @@ async fn main() -> Result<()> {
157132
);
158133
println!();
159134

160-
// Step 7: Public Keys
161-
println!("7️⃣ Public Keys");
135+
// Step 6: Public Keys
136+
println!("6️⃣ Public Keys");
162137

163138
// Get public keys for different algorithms
164139
let schnorr_pub = client
@@ -186,8 +161,8 @@ async fn main() -> Result<()> {
186161
);
187162
println!();
188163

189-
// Step 8: Data Encryption
190-
println!("8️⃣ End-to-End Encryption");
164+
// Step 7: Data Encryption
165+
println!("7️⃣ End-to-End Encryption");
191166
let secret_data = "This is highly confidential information";
192167

193168
// Encrypt data
@@ -215,8 +190,8 @@ async fn main() -> Result<()> {
215190
);
216191
println!();
217192

218-
// Step 9: Third-Party Tokens
219-
println!("9️⃣ Third-Party Token Generation");
193+
// Step 8: Third-Party Tokens
194+
println!("8️⃣ Third-Party Token Generation");
220195

221196
// Generate token without audience
222197
let token = client.generate_third_party_token(None).await?;
@@ -234,8 +209,8 @@ async fn main() -> Result<()> {
234209
);
235210
println!();
236211

237-
// Step 10: Session Management
238-
println!("🔟 Session Management");
212+
// Step 9: Session Management
213+
println!("9️⃣ Session Management");
239214

240215
// Refresh access token
241216
println!(" Refreshing tokens...");

‎sdk/rust/src/client.rs‎

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,40 +1971,6 @@ impl OpenSecretClient {
19711971
Ok(())
19721972
}
19731973

1974-
// Key-Value Storage APIs
1975-
pub async fn kv_get(&self, key: &str) -> Result<String> {
1976-
let encoded_key = utf8_percent_encode(key, NON_ALPHANUMERIC).to_string();
1977-
let url = format!("/protected/kv/{}", encoded_key);
1978-
self.authenticated_api_call(&url, "GET", None::<()>).await
1979-
}
1980-
1981-
pub async fn kv_put(&self, key: &str, value: String) -> Result<String> {
1982-
let encoded_key = utf8_percent_encode(key, NON_ALPHANUMERIC).to_string();
1983-
let url = format!("/protected/kv/{}", encoded_key);
1984-
self.authenticated_api_call(&url, "PUT", Some(value)).await
1985-
}
1986-
1987-
pub async fn kv_delete(&self, key: &str) -> Result<()> {
1988-
let encoded_key = utf8_percent_encode(key, NON_ALPHANUMERIC).to_string();
1989-
let url = format!("/protected/kv/{}", encoded_key);
1990-
let _: serde_json::Value = self
1991-
.authenticated_api_call(&url, "DELETE", None::<()>)
1992-
.await?;
1993-
Ok(())
1994-
}
1995-
1996-
pub async fn kv_delete_all(&self) -> Result<()> {
1997-
let _: serde_json::Value = self
1998-
.authenticated_api_call("/protected/kv", "DELETE", None::<()>)
1999-
.await?;
2000-
Ok(())
2001-
}
2002-
2003-
pub async fn kv_list(&self) -> Result<Vec<KVListItem>> {
2004-
self.authenticated_api_call("/protected/kv", "GET", None::<()>)
2005-
.await
2006-
}
2007-
20081974
// Private Key APIs
20091975
pub async fn get_private_key(&self, options: Option<KeyOptions>) -> Result<PrivateKeyResponse> {
20101976
let mut url = "/protected/private_key".to_string();

‎sdk/rust/src/types.rs‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -355,15 +355,6 @@ pub struct DeletedPushDeviceResponse {
355355
pub deleted: bool,
356356
}
357357

358-
// Key-Value Storage Types
359-
#[derive(Debug, Clone, Serialize, Deserialize)]
360-
pub struct KVListItem {
361-
pub key: String,
362-
pub value: String,
363-
pub created_at: i64, // Unix timestamp
364-
pub updated_at: i64, // Unix timestamp
365-
}
366-
367358
// Private Key Types
368359
#[derive(Debug, Clone, Serialize, Deserialize)]
369360
pub struct KeyOptions {

‎sdk/rust/tests/api_integration.rs‎

Lines changed: 0 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -47,171 +47,6 @@ async fn test_user_profile_api() -> Result<()> {
4747
Ok(())
4848
}
4949

50-
#[tokio::test]
51-
async fn test_kv_storage_apis() -> Result<()> {
52-
// Load environment variables
53-
let env_path = std::path::Path::new("../.env.local");
54-
if env_path.exists() {
55-
dotenvy::from_path(env_path).ok();
56-
}
57-
58-
let base_url = std::env::var("VITE_OPEN_SECRET_API_URL")
59-
.unwrap_or_else(|_| "http://localhost:3000".to_string());
60-
let client_id = std::env::var("VITE_TEST_CLIENT_ID")
61-
.ok()
62-
.and_then(|id| Uuid::parse_str(&id).ok())
63-
.expect("VITE_TEST_CLIENT_ID must be set");
64-
65-
// Create client and login as guest for isolation
66-
let client = common::new_test_client(base_url)?;
67-
client.perform_attestation_handshake().await?;
68-
69-
let guest_password = "test_kv_password";
70-
client
71-
.register_guest(guest_password.to_string(), client_id)
72-
.await?;
73-
74-
// Test KV operations
75-
let test_key = "test_key_rust";
76-
let test_value = "test_value_from_rust_sdk";
77-
78-
// PUT
79-
let put_result = client.kv_put(test_key, test_value.to_string()).await?;
80-
assert_eq!(put_result, test_value);
81-
println!("✓ KV PUT successful");
82-
83-
// GET
84-
let get_result = client.kv_get(test_key).await?;
85-
assert_eq!(get_result, test_value);
86-
println!("✓ KV GET successful");
87-
88-
// LIST
89-
let list_result = client.kv_list().await?;
90-
assert!(list_result.iter().any(|item| item.key == test_key));
91-
println!("✓ KV LIST successful");
92-
93-
// DELETE
94-
client.kv_delete(test_key).await?;
95-
println!("✓ KV DELETE successful");
96-
97-
// Verify deletion
98-
let list_after_delete = client.kv_list().await?;
99-
assert!(!list_after_delete.iter().any(|item| item.key == test_key));
100-
println!("✓ KV deletion verified");
101-
102-
Ok(())
103-
}
104-
105-
#[tokio::test]
106-
async fn test_kv_delete_all() -> Result<()> {
107-
// Load environment variables
108-
let env_path = std::path::Path::new("../.env.local");
109-
if env_path.exists() {
110-
dotenvy::from_path(env_path).ok();
111-
}
112-
113-
let base_url = std::env::var("VITE_OPEN_SECRET_API_URL")
114-
.unwrap_or_else(|_| "http://localhost:3000".to_string());
115-
let client_id = std::env::var("VITE_TEST_CLIENT_ID")
116-
.ok()
117-
.and_then(|id| Uuid::parse_str(&id).ok())
118-
.expect("VITE_TEST_CLIENT_ID must be set");
119-
120-
// Create client and login as guest for isolation
121-
let client = common::new_test_client(base_url)?;
122-
client.perform_attestation_handshake().await?;
123-
124-
client
125-
.register_guest("test_kv_delete_all".to_string(), client_id)
126-
.await?;
127-
128-
// Add multiple keys
129-
client.kv_put("key1", "value1".to_string()).await?;
130-
client.kv_put("key2", "value2".to_string()).await?;
131-
client.kv_put("key3", "value3".to_string()).await?;
132-
133-
// Verify they exist
134-
let list_result = client.kv_list().await?;
135-
assert!(list_result.len() >= 3);
136-
println!("✓ Keys added successfully");
137-
138-
// Delete all
139-
client.kv_delete_all().await?;
140-
println!("✓ kv_delete_all called");
141-
142-
// Verify empty
143-
let list_after_delete = client.kv_list().await?;
144-
assert!(list_after_delete.is_empty());
145-
println!("✓ All keys deleted successfully");
146-
147-
Ok(())
148-
}
149-
150-
#[tokio::test]
151-
async fn test_kv_storage_with_special_characters() -> Result<()> {
152-
// Load environment variables
153-
let env_path = std::path::Path::new("../.env.local");
154-
if env_path.exists() {
155-
dotenvy::from_path(env_path).ok();
156-
}
157-
158-
let base_url = std::env::var("VITE_OPEN_SECRET_API_URL")
159-
.unwrap_or_else(|_| "http://localhost:3000".to_string());
160-
let client_id = std::env::var("VITE_TEST_CLIENT_ID")
161-
.ok()
162-
.and_then(|id| Uuid::parse_str(&id).ok())
163-
.expect("VITE_TEST_CLIENT_ID must be set");
164-
165-
// Create client and login
166-
let client = common::new_test_client(base_url)?;
167-
client.perform_attestation_handshake().await?;
168-
client
169-
.register_guest("test_kv_special".to_string(), client_id)
170-
.await?;
171-
172-
// Test with various special characters that need URL encoding
173-
let test_cases = vec![
174-
("key/with/slashes", "value1"),
175-
("key?with=query&params", "value2"),
176-
("key#with#hash", "value3"),
177-
("key with spaces", "value4"),
178-
("key%with%percents", "value5"),
179-
("key@with!special$chars", "value6"),
180-
("key[with]brackets{and}braces", "value7"),
181-
("key:with:colons;semicolons", "value8"),
182-
];
183-
184-
for (key, value) in &test_cases {
185-
println!("Testing key: {:?}", key);
186-
187-
// PUT with special characters
188-
let put_result = client.kv_put(key, value.to_string()).await?;
189-
assert_eq!(put_result, *value);
190-
191-
// GET with special characters
192-
let get_result = client.kv_get(key).await?;
193-
assert_eq!(get_result, *value);
194-
195-
// DELETE with special characters
196-
client.kv_delete(key).await?;
197-
198-
println!("✓ KV operations successful for key: {:?}", key);
199-
}
200-
201-
// Verify all were deleted
202-
let final_list = client.kv_list().await?;
203-
for (key, _) in &test_cases {
204-
assert!(
205-
!final_list.iter().any(|item| item.key == *key),
206-
"Key {:?} should have been deleted",
207-
key
208-
);
209-
}
210-
println!("✓ All special character keys handled correctly");
211-
212-
Ok(())
213-
}
214-
21550
#[tokio::test]
21651
async fn test_private_key_generation() -> Result<()> {
21752
// Load environment variables

‎sdk/src/lib/api.ts‎

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,6 @@ function installCredentialUpdate(
9898
);
9999
}
100100

101-
export type KVListItem = {
102-
key: string;
103-
value: string;
104-
created_at: number;
105-
updated_at: number;
106-
};
107-
108101
export async function fetchLogin(
109102
email: string,
110103
password: string,
@@ -216,59 +209,6 @@ export async function fetchUserWithTransportV2Authority(
216209
);
217210
}
218211

219-
export async function fetchPut(key: string, value: string): Promise<string> {
220-
return authenticatedApiCall<string, string>(
221-
`${apiUrl}/protected/kv/${key}`,
222-
"PUT",
223-
value,
224-
"Failed to put key-value pair"
225-
);
226-
}
227-
228-
export async function fetchDelete(key: string, expectedUserId?: string): Promise<void> {
229-
return authenticatedApiCall<void, void>(
230-
`${apiUrl}/protected/kv/${key}`,
231-
"DELETE",
232-
undefined,
233-
"Failed to delete key-value pair",
234-
expectedUserId
235-
);
236-
}
237-
238-
export async function fetchDeleteAllKV(expectedUserId?: string): Promise<void> {
239-
return authenticatedApiCall<void, void>(
240-
`${apiUrl}/protected/kv`,
241-
"DELETE",
242-
undefined,
243-
"Failed to delete all key-value pairs",
244-
expectedUserId
245-
);
246-
}
247-
248-
export async function fetchGet(key: string): Promise<string | undefined> {
249-
try {
250-
const data = await authenticatedApiCall<void, string>(
251-
`${apiUrl}/protected/kv/${key}`,
252-
"GET",
253-
undefined,
254-
"Failed to get key-value pair"
255-
);
256-
return data;
257-
} catch (error) {
258-
console.error(`Error fetching key "${key}":`, error);
259-
return undefined;
260-
}
261-
}
262-
263-
export async function fetchList(): Promise<KVListItem[]> {
264-
return authenticatedApiCall<void, KVListItem[]>(
265-
`${apiUrl}/protected/kv`,
266-
"GET",
267-
undefined,
268-
"Failed to list key-value pairs"
269-
);
270-
}
271-
272212
export async function fetchLogout(refresh_token: string): Promise<void> {
273213
const refreshData = { refresh_token };
274214
return encryptedApiCall<typeof refreshData, void>(`${apiUrl}/logout`, "POST", refreshData);

0 commit comments

Comments
 (0)