Present a W3C VC
Present a Credential with OID4VP
1. Create a PermissionRequest
import SpruceIDMobileSdkRs
import SpruceIDMobileSdk
import SwiftUI
// 1. Define a function to present a Credential that results in a PermissionRequest
func presentCredential(url: String) async {
do {
// Load your CredentialPacks using your storageManager
let storageManager = StorageManager()
credentialPacks = try CredentialPack.loadAll(storageManager: storageManager)
var credentials: [ParsedCredential] = []
credentialPacks.forEach { credentialPack in
credentials += credentialPack.list()
credentialClaims = credentialClaims.merging(
credentialPack.findCredentialClaims(claimNames: ["name", "type"])
) { (_, new) in new }
}
// Instantiate a signer based on a KeyId
let signer = try Signer(keyId: "KeyID")
// Define your holder component with context
// In this example, we use a function that sets context for VC Playground credentials
holder = try await Holder.newWithCredentials(
providedCredentials: credentials,
trustedDids: trustedDids,
signer: signer,
contextMap: getVCPlaygroundOID4VCIContext()
)
// Create a permission Request
permissionRequest = try await holder!.authorizationRequest(url: Url(url))
} catch {
err = error.localizedDescription
}
}
2. The user selects the credential (and data fields)
3. Create and Submit a PermissionResponse
Last updated
Was this helpful?