Skip to content

Commit

Permalink
[Android][iOS] Resolve status list for VCDM2SdJwt credentials (#79)
Browse files Browse the repository at this point in the history
This updates the apps to resolve status lists for VCDM2SdJwts

Signed-off-by: Ryan Tate <[email protected]>
Co-authored-by: Ryan Tate <[email protected]>
  • Loading branch information
Juliano1612 and Ryanmtate authored Jan 17, 2025
1 parent 560f482 commit 3caabee
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/spruceid/mobile-sdk-rs.git",
"state" : {
"revision" : "60467b604eeafe5faa824bcd5eecad41ea1efbeb",
"version" : "0.4.3"
"revision" : "b75c5d9a6f4dfccc20879c76d309217ba7494d79",
"version" : "0.7.0"
}
},
{
Expand Down
40 changes: 32 additions & 8 deletions Sources/MobileSdk/CredentialPack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,27 @@ public class CredentialPack {
} else {
res[credentialId] = CredentialStatusList.valid
}
} catch {}
} catch {
res[credentialId] = CredentialStatusList.undefined}
} else {
res[credentialId] = CredentialStatusList.unknown
}
} else if let cred = credential.asSdJwt() {
if hasConnection {
do {
let status = try await cred.status()
res[credentialId] = CredentialStatusList.valid
for credentialStatus in status {
if credentialStatus.isRevoked() {
res[credentialId] = CredentialStatusList.revoked
break
} else if credentialStatus.isSuspended() {
res[credentialId] = CredentialStatusList.suspended
}
}
} catch {
res[credentialId] = CredentialStatusList.undefined
}
} else {
res[credentialId] = CredentialStatusList.unknown
}
Expand Down Expand Up @@ -385,17 +405,21 @@ enum CredentialPackError: Error {
case credentialParsing(reason: String)
}

public enum CredentialStatusList {
public enum CredentialStatusList: String {
init?(from string: String) {
self.init(rawValue: string.uppercased())
}

/// Valid credential
case valid
case valid = "VALID"
/// Credential revoked
case revoked
case revoked = "REVOKED"
/// Credential suspended
case suspended
case suspended = "SUSPENDED"
/// No connection
case unknown
case unknown = "UNKNOWN"
/// Invalid credential
case invalid
case invalid = "INVALID"
/// Credential doesn't have status list
case undefined
case undefined = "UNDEFINED"
}
2 changes: 1 addition & 1 deletion Sources/MobileSdk/IsoMdlPresentation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class IsoMdlPresentation {
return
}
let response = try session.submitResponse(
derSignature: derSignature)
signature: derSignature)
self.bleManager.writeOutgoingValue(data: response)
} catch {
self.callback.update(state: .error(.generic("\(error)")))
Expand Down

0 comments on commit 3caabee

Please sign in to comment.