Affinidi TDK - Claim Verifiable Credential
The Affinidi TDK - Claim Verifiable Credential package provides the libraries with the ability to find and claim Verifiable Credentials issued to users from the Credential Issuer Service.
Key Features
- Load credential offers from URIs.
- Claim Verifiable Credentials (VCs) into your cloud profiles.
- Support for transaction code verification when claiming a VC.
- Error handling for common credential claiming scenarios.
Requirements
- Dart SDK version ^3.6.0
Installation
Run:
dart pub add affinidi_tdk_claim_verifiable_credential
or manually add the package to your pubspec.yaml
file:
dependencies:
affinidi_tdk_claim_verifiable_credential: ^<version_number>
and then run the command below to install the package:
dart pub get
For more information, visit the pub.dev install page of the Affinidi TDK - Claim Verifiable Credential package.
Usage
After successfully installing the package, import it into your code.
import 'dart:typed_data';
import 'package:affinidi_tdk_claim_verifiable_credential/oid4vci_claim_verifiable_credential.dart';
void main() async {
// Create an instance of CredentialClaimService
final credentialService = CredentialClaimService(
seed: <yourSeedBytes>, // Uint8List containing your seed
);
// Generate the did document using publicKey
final didDocument = DidKey.generateDocument(keyPair.publicKey);
// Create an instance of DidSigner
final signer = DidSigner(
didDocument: didDocument,
didKeyId: didDocument.verificationMethod.first.id,
keyPair: keyPair,
signatureScheme: SignatureScheme.ecdsa_secp256k1_sha256,
);
// Create a new instance of ClaimVerifiableCredentialService with the created didSigner
final claimVerifiableCredentialService = OID4VCIClaimVerifiableCredentialService(didSigner: signer,);
// Parse the credential offer url
final uri = Uri.parse(
'https://example.com/callback?credential_offer_uri=https://issuer.example.com/offer/123',
);
// Load creantialOffer
final context = await claimVerifiableCredentialService.loadCredentialOffer(uri);
// claim the credential
final credential = await claimVerifiableCredentialService.claimCredential(
claimContext: context,
);
}
For more sample usage, go to the example folder.
Support & feedback
If you face any issues or have suggestions, please don't hesitate to contact us using this link.
Reporting technical issues
If you have a technical issue with the package's codebase, you can also create an issue directly in GitHub.
-
Ensure the bug was not already reported by searching on GitHub under Issues.
-
If you're unable to find an open issue addressing the problem, open a new one. Be sure to include a title and clear description, as much relevant information as possible, and a code sample or an executable test case demonstrating the expected behaviour that is not occurring.
Contributing
Want to contribute?
Head over to our CONTRIBUTING guidelines.
Libraries
- oid4vci_claim_verifiable_credential
- This library allows retrieving credential offers and claiming them