-
Notifications
You must be signed in to change notification settings - Fork 3
feat: sign client #192
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
feat: sign client #192
Conversation
* feat: Rust sample wallet * uniffi * savepoint * savepoint * savepoint * savepoint * savepoint * cleanup * savepoint * mutex client * savepoint --------- Co-authored-by: Chris Smith <[email protected]>
bf7bd38
to
4fa11e1
Compare
a981230
to
e3612a6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request adds session persistence functionality to the Yttrium Sign client, allowing sessions to be maintained across application restarts. The implementation includes client state management, cryptographic key persistence, and enhanced session handling capabilities.
Key changes:
- Session storage and retrieval with encrypted state persistence
- Cryptographic utilities for topic generation and Diffie-Hellman key exchange
- Comprehensive session request handling and WebSocket message processing
- End-to-end testing infrastructure with Playwright
Reviewed Changes
Copilot reviewed 14 out of 16 changed files in this pull request and generated 6 comments.
Show a summary per file
File | Description |
---|---|
crates/yttrium/src/sign/utils.rs |
Adds cryptographic utilities for topic generation and key exchange |
crates/yttrium/src/sign/protocol_types.rs |
Defines JSON-RPC message structures for session management |
crates/yttrium/src/sign/mod.rs |
Major refactor to support session persistence and improved WebSocket handling |
crates/rust-sample-wallet/src/app.rs |
New UI component for session management with local storage integration |
crates/rust-sample-wallet/src/main.rs |
Simplified main entry point with logging configuration |
Other files | Supporting files for testing infrastructure and UI components |
Files not reviewed (1)
- crates/rust-sample-wallet/package-lock.json: Language not supported
) -> [u8; 32] { | ||
let shared_key = private_key.diffie_hellman(public_key); | ||
let derived_key = hkdf::Hkdf::<Sha256>::new(None, shared_key.as_bytes()); | ||
let mut expanded_key = [0u8; 32]; | ||
derived_key.expand(b"", &mut expanded_key).unwrap(); | ||
expanded_key |
Copilot
AI
Jul 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The unwrap() call should be replaced with proper error handling. HKDF expand operations can fail and should return a proper error type instead of panicking.
) -> [u8; 32] { | |
let shared_key = private_key.diffie_hellman(public_key); | |
let derived_key = hkdf::Hkdf::<Sha256>::new(None, shared_key.as_bytes()); | |
let mut expanded_key = [0u8; 32]; | |
derived_key.expand(b"", &mut expanded_key).unwrap(); | |
expanded_key | |
) -> Result<[u8; 32], hkdf::InvalidLength> { | |
let shared_key = private_key.diffie_hellman(public_key); | |
let derived_key = hkdf::Hkdf::<Sha256>::new(None, shared_key.as_bytes()); | |
let mut expanded_key = [0u8; 32]; | |
derived_key.expand(b"", &mut expanded_key)?; | |
Ok(expanded_key) |
Copilot uses AI. Check for mistakes.
crates/yttrium/src/sign/mod.rs
Outdated
if let Err(e) = | ||
response_tx.send(response) | ||
{ | ||
web_sys::console::log_1(&format!("Failed to send response: {e:?}").into()); |
Copilot
AI
Jul 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using web_sys::console::log_1 for error handling in production code is not ideal. Consider using the tracing crate which is already imported for consistent logging.
web_sys::console::log_1(&format!("Failed to send response: {e:?}").into()); | |
tracing::error!("Failed to send response: {:?}", e); |
Copilot uses AI. Check for mistakes.
crates/yttrium/src/sign/mod.rs
Outdated
Payload::Response(response) => { | ||
if let Some(response_tx) = response_channels.remove(&response.id()) { | ||
if let Err(e) = response_tx.send(response) { | ||
web_sys::console::log_1(&format!("Failed to send response: {e:?}").into()); |
Copilot
AI
Jul 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate error logging pattern using web_sys::console::log_1. This should be consistent with the tracing infrastructure used elsewhere in the codebase.
web_sys::console::log_1(&format!("Failed to send response: {e:?}").into()); | |
tracing::error!("Failed to send response: {:?}", e); |
Copilot uses AI. Check for mistakes.
crates/yttrium/src/sign/mod.rs
Outdated
// TODO may not be string messages | ||
let message = event.data().as_string().unwrap(); | ||
tx.send(message).unwrap(); | ||
web_sys::console::log_1(&message.clone().into()); |
Copilot
AI
Jul 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug logging using web_sys::console::log_1 should be replaced with tracing::debug! for consistency with the logging infrastructure.
web_sys::console::log_1(&message.clone().into()); | |
tracing::debug!("{}", message.clone()); |
Copilot uses AI. Check for mistakes.
crates/yttrium/src/sign/mod.rs
Outdated
result: serde_json::to_value(true).expect("TODO"), | ||
jsonrpc: "2.0".to_string().into(), | ||
})); | ||
let serialized = serde_json::to_string(&request).map_err(|e| { | ||
RequestError::ShouldNeverHappen(format!( | ||
"Failed to serialize request: {e}" | ||
)) | ||
}).expect("TODO"); |
Copilot
AI
Jul 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expect("TODO") indicates incomplete error handling. This should be replaced with proper error propagation or a more descriptive error message.
result: serde_json::to_value(true).expect("TODO"), | |
jsonrpc: "2.0".to_string().into(), | |
})); | |
let serialized = serde_json::to_string(&request).map_err(|e| { | |
RequestError::ShouldNeverHappen(format!( | |
"Failed to serialize request: {e}" | |
)) | |
}).expect("TODO"); | |
result: serde_json::to_value(true).map_err(|e| { | |
RequestError::Internal(format!( | |
"Failed to serialize result: {e}" | |
)) | |
})?, | |
jsonrpc: "2.0".to_string().into(), | |
})); | |
let serialized = serde_json::to_string(&request).map_err(|e| { | |
RequestError::ShouldNeverHappen(format!( | |
"Failed to serialize request: {e}" | |
)) | |
})?; |
Copilot uses AI. Check for mistakes.
crates/yttrium/src/sign/mod.rs
Outdated
let serialized = serde_json::to_string(&request).map_err(|e| { | ||
RequestError::ShouldNeverHappen(format!( | ||
"Failed to serialize request: {e}" | ||
)) | ||
}).expect("TODO"); | ||
ws.send_with_str(&serialized).expect("TODO"); |
Copilot
AI
Jul 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another expect("TODO") that should be replaced with proper error handling to avoid potential panics in production code.
Copilot uses AI. Check for mistakes.
e3612a6
to
d69ce35
Compare
d69ce35
to
566e092
Compare
b09b62d
to
564f24d
Compare
…/yttrium into expose_session_request
feat: Add on session rejected
feat: expose session request
* ios: update features for xcframework build (#201) * savepoint * savepoint * savepoint * savepoint * savepoint * chore: update Package.swift and podspec for version 0.9.4 * chore: update Package.swift and podspec for version 0.9.45 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * iOS: Package split (#203) * savepoint * savepoint * savepoint * savepoint * savepoint * chore: update Package.swift and podspec for version 0.9.4 * chore: update Package.swift and podspec for version 0.9.45 * savepoint * savepoint * savepoint * add podspec update utils workflow * savepoint * update workflows * fix ci --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: update Package.swift, utils sources, and podspec for version 0.9.46 * support for 16kb pages * Update gradle.properties Co-authored-by: Copilot <[email protected]> * Update crates/kotlin-ffi/android/build.gradle Co-authored-by: Copilot <[email protected]> * update * change profile for local build * iOS: Package split 2 (#204) * savepoint * savepoint * savepoint * savepoint * savepoint * chore: update Package.swift and podspec for version 0.9.4 * chore: update Package.swift and podspec for version 0.9.45 * savepoint * savepoint * savepoint * add podspec update utils workflow * savepoint * update workflows * fix ci * savepoint * fix pods * savepoint * test * chore: update Package.swift, utils sources, and podspec for version 0.9.50 * rename utils modulemap * chore: update Package.swift, utils sources, and podspec for version 0.9.52 * fix yttrium conflict * update ignore * utils(build): enable Sui, namespace FFI (yttriumUtilsFFI), rename libyttrium-utils.a; update build script * add sui * savepoint * select xcode * chore: update Package.swift, utils sources, and podspec for version 0.9.56 * savepoint * remove prepare from cocoapods * savepoint * chore: update Package.swift, utils sources, and podspec for version 0.9.59 * SPM works * chore: update Package.swift and podspec for version 0.9.60 * chore: update Package.swift, utils sources, and podspec for version 0.9.61 * fix(utils-spm): package XCFramework zip with top-level libyttrium-utils.xcframework directory for SPM * chore: update Package.swift, utils sources, and podspec for version 0.9.62 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: update Package.swift and podspec for version 0.9.63 * chore: update Package.swift, utils sources, and podspec for version 0.9.64 * chore: update Package.swift and podspec for version 0.9.67 * Ios deployment target fix (#208) * savepoint * savepoint * savepoint * savepoint * savepoint * chore: update Package.swift and podspec for version 0.9.4 * chore: update Package.swift and podspec for version 0.9.45 * savepoint * savepoint * savepoint * add podspec update utils workflow * savepoint * update workflows * fix ci * savepoint * fix pods * savepoint * test * chore: update Package.swift, utils sources, and podspec for version 0.9.50 * rename utils modulemap * chore: update Package.swift, utils sources, and podspec for version 0.9.52 * fix yttrium conflict * update ignore * utils(build): enable Sui, namespace FFI (yttriumUtilsFFI), rename libyttrium-utils.a; update build script * add sui * savepoint * select xcode * chore: update Package.swift, utils sources, and podspec for version 0.9.56 * savepoint * remove prepare from cocoapods * savepoint * chore: update Package.swift, utils sources, and podspec for version 0.9.59 * SPM works * chore: update Package.swift and podspec for version 0.9.60 * chore: update Package.swift, utils sources, and podspec for version 0.9.61 * fix(utils-spm): package XCFramework zip with top-level libyttrium-utils.xcframework directory for SPM * update scripts * chore: update Package.swift and podspec for version 0.9.65 * chore: update Package.swift, utils sources, and podspec for version 0.9.66 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: update Package.swift and podspec for version 0.9.68 * savepoint * lint --------- Co-authored-by: Bartosz Rozwarski <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: jakubuid <[email protected]> Co-authored-by: Copilot <[email protected]>
feat: session emit event
433547b
to
0418029
Compare
No description provided.