Skip to content

Commit

Permalink
wip: add TODOs and stage changes
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Tate <[email protected]>
  • Loading branch information
Ryanmtate committed Aug 27, 2024
1 parent 247fe61 commit 2d46846
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ package_kotlin: kotlin

# Package Swift code
package_swift: swift
$(CARGO) swift package -p ios -n MobileSdkRs
$(CARGO) swift package -p ios -n MobileSdkRs --release

# Package the Swift and Kotlin code
package: package_kotlin package_swift
Expand Down
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ let package = Package(
targets: ["SpruceIDMobileSdkRs"]
)
],
dependencies: [ ],
dependencies: [],
targets: [
.binaryTarget(name: "RustFramework", url: "https://github.com/spruceid/mobile-sdk-rs/releases/download/0.0.28/RustFramework.xcframework.zip", checksum: "a783beb8c08aa4c3153aaf84746d5c0c77e234ebd121f10b8aae022e9ad63e52"),
// .binaryTarget(name: "RustFramework", url: "https://github.com/spruceid/mobile-sdk-rs/releases/download/0.0.28/RustFramework.xcframework.zip", checksum: "a783beb8c08aa4c3153aaf84746d5c0c77e234ebd121f10b8aae022e9ad63e52"),
//.binaryTarget(name: "RustFramework", url: "https://github.com/spruceid/mobile-sdk-rs/releases/download/0.0.27/RustFramework.xcframework.zip", checksum: "41af2b922038d6c068d9fafd48f901ac2e33e53cde8e1b5bc18cd8f2977a9585"),
.binaryTarget(name: "RustFramework", path: "./MobileSdkRs/RustFramework.xcframework"),
.target(
name: "SpruceIDMobileSdkRs",
dependencies: [
Expand Down
5 changes: 5 additions & 0 deletions src/credentials_callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,17 @@ pub trait CredentialCallbackInterface: Send + Sync + Debug {
/// If the user denies the a field request, the verifier should return a [CredentialCallbackError::PermissionDenied]
fn permit_presentation(
&self,
// TODO: Should include a uniffi::Object with method handlers for purpose and description, etc.
// TODO: Selective disclosure of credential. Bool -> `is_selectively_disclosable`.
requested_fields: Vec<String>,
// TODO: Consider returning a `selective disclosure` object that includes the requested fields.
) -> Result<(), CredentialCallbackError>;

/// Select which credentials to present provided a list of matching credentials.
///
/// This is called by the client to select which credentials to present to the verifier. Multiple credentials
/// may satisfy the request, and the client should select the most appropriate credentials to present.
fn select_credentials(&self, credentials: Vec<Arc<Credential>>) -> Vec<Arc<Credential>>;

// TODO: Selective disclosure of credential attributes.
}
64 changes: 34 additions & 30 deletions src/metadata_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ impl From<uniffi::UnexpectedUniFFICallbackError> for MetadataManagerError {
/// Use the [MetadataManager::cache] method to access a reference to the wallet metadata.
#[derive(Debug)]
pub struct MetadataManager {
// TODO: Remove a singular cache;
// There may be multiple types of wallet metadata required per protocol.
cache: WalletMetadata,
}

Expand All @@ -60,36 +62,38 @@ impl MetadataManager {
}
}

/// Add a new supported request object signing algorithm to the wallet metadata.
pub fn add_request_object_signing_alg(
&mut self,
algorithm: String,
storage: &Box<dyn StorageManagerInterface>,
) -> Result<(), MetadataManagerError> {
self.cache
.add_request_object_signing_alg(algorithm)
.map_err(|e| MetadataManagerError::RequestObjectSigningAlgorithm(e.to_string()))?;

// Overwrite the metadata with the new algorithm.
Self::add_metadata(&self.cache, storage)
}

/// Add a new claim format algorithm supported to the wallet.
pub fn add_claim_format_alg_values_supported(
&mut self,
algorithm: String,
claim_format: &ClaimFormatDesignation,
storage: &Box<dyn StorageManagerInterface>,
) -> Result<(), MetadataManagerError> {
self.cache
.vp_formats_supported_mut()
.0
.get_mut(claim_format)
.map(|formats| formats.add_alg(algorithm));

// Overwrite the metadata with the new algorithm.
Self::add_metadata(&self.cache, storage)
}
// NOTE: Provide a mutable reference to the wallet metadata.

// /// Add a new supported request object signing algorithm to the wallet metadata.
// pub fn add_request_object_signing_alg(
// &mut self,
// algorithm: String,
// storage: &Box<dyn StorageManagerInterface>,
// ) -> Result<(), MetadataManagerError> {
// self.cache
// .add_request_object_signing_alg(algorithm)
// .map_err(|e| MetadataManagerError::RequestObjectSigningAlgorithm(e.to_string()))?;

// // Overwrite the metadata with the new algorithm.
// Self::add_metadata(&self.cache, storage)
// }

// /// Add a new claim format algorithm supported to the wallet.
// pub fn add_claim_format_alg_values_supported(
// &mut self,
// algorithm: String,
// claim_format: &ClaimFormatDesignation,
// storage: &Box<dyn StorageManagerInterface>,
// ) -> Result<(), MetadataManagerError> {
// self.cache
// .vp_formats_supported_mut()
// .0
// .get_mut(claim_format)
// .map(|formats| formats.add_alg(algorithm));

// // Overwrite the metadata with the new algorithm.
// Self::add_metadata(&self.cache, storage)
// }

/// Returns a reference to the wallet metadata.
///
Expand Down
3 changes: 3 additions & 0 deletions src/oid4vp/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,9 @@ impl RequestVerifier for Wallet {
}
}

// TODO: The wallet should provide a `factory` for wallet instances
// that implement the protocol-sepecific traits, e.g. `Wallet` in OID4VP.

impl OID4VPWallet for Wallet {
type HttpClient = oid4vp::core::util::ReqwestClient;

Expand Down
1 change: 1 addition & 0 deletions src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ impl Wallet {
pub async fn handle_oid4vp_request(
&self,
url: Url,
// NOTE: The callback handles UI interactions.
callback: &Box<dyn CredentialCallbackInterface>,
) -> Result<Option<Url>, WalletError> {
let request = self
Expand Down

0 comments on commit 2d46846

Please sign in to comment.