Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Add convenience functions to ParsedCredential #55

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions MobileSdkRs/Sources/MobileSdkRs/mobile_sdk_rs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2722,11 +2722,21 @@ public protocol ParsedCredentialProtocol : AnyObject {
*/
func asMsoMdoc() -> Mdoc?

/**
* Get the local ID for this credential.
*/
func id() -> Uuid

/**
* Convert a parsed credential into the generic form for storage.
*/
func intoGenericForm() throws -> Credential

/**
* Get the key alias for this credential.
*/
func keyAlias() -> KeyAlias?

}

/**
Expand Down Expand Up @@ -2856,6 +2866,16 @@ open func asMsoMdoc() -> Mdoc? {
uniffi_mobile_sdk_rs_fn_method_parsedcredential_as_mso_mdoc(self.uniffiClonePointer(),$0
)
})
}

/**
* Get the local ID for this credential.
*/
open func id() -> Uuid {
return try! FfiConverterTypeUuid.lift(try! rustCall() {
uniffi_mobile_sdk_rs_fn_method_parsedcredential_id(self.uniffiClonePointer(),$0
)
})
}

/**
Expand All @@ -2868,6 +2888,16 @@ open func intoGenericForm()throws -> Credential {
})
}

/**
* Get the key alias for this credential.
*/
open func keyAlias() -> KeyAlias? {
return try! FfiConverterOptionTypeKeyAlias.lift(try! rustCall() {
uniffi_mobile_sdk_rs_fn_method_parsedcredential_key_alias(self.uniffiClonePointer(),$0
)
})
}


}

Expand Down Expand Up @@ -7966,9 +7996,15 @@ private var initializationResult: InitializationResult = {
if (uniffi_mobile_sdk_rs_checksum_method_parsedcredential_as_mso_mdoc() != 54804) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_mobile_sdk_rs_checksum_method_parsedcredential_id() != 46894) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_mobile_sdk_rs_checksum_method_parsedcredential_into_generic_form() != 30318) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_mobile_sdk_rs_checksum_method_parsedcredential_key_alias() != 52023) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_mobile_sdk_rs_checksum_method_storagemanagerinterface_add() != 39162) {
return InitializationResult.apiChecksumMismatch
}
Expand Down
20 changes: 20 additions & 0 deletions src/credential/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,26 @@ impl ParsedCredential {
}
}

/// Get the local ID for this credential.
pub fn id(&self) -> Uuid {
match &self.inner {
ParsedCredentialInner::MsoMdoc(arc) => arc.id(),
ParsedCredentialInner::JwtVcJson(arc) => arc.id(),
ParsedCredentialInner::JwtVcJsonLd(arc) => arc.id(),
ParsedCredentialInner::LdpVc(arc) => arc.id(),
}
}

/// Get the key alias for this credential.
pub fn key_alias(&self) -> Option<KeyAlias> {
match &self.inner {
ParsedCredentialInner::MsoMdoc(arc) => Some(arc.key_alias()),
ParsedCredentialInner::JwtVcJson(arc) => arc.key_alias(),
ParsedCredentialInner::JwtVcJsonLd(arc) => arc.key_alias(),
ParsedCredentialInner::LdpVc(arc) => arc.key_alias(),
}
}

/// Return the credential as a JwtVc if it is of that format.
pub fn as_jwt_vc(&self) -> Option<Arc<JwtVc>> {
match &self.inner {
Expand Down
Loading