Credentials
These methods let a cloud wallet receive and manage credentials: look at a credential offer, accept or decline it, and list or delete stored credentials. They act on one wallet, so create the CloudWallet with that wallet's access token (see Authentication).
Most methods take a protocol: use 'openid' for EU Digital Identity credentials and 'didcomm' for cheqd and Indicio credentials.
- Resolve credential offer URI
- Preview credential offer
- Accept credential offer
- Decline credential offer
- Delete credential
- Get credential offers
- Get stored credentials
Resolve credential offer URI
Reads an EU Digital Identity credential offer URI (resolveOpenIdUri) and returns the offer's details.
import { CloudWallet } from '@hovi/cloudwallet-sdk';
const wallet = new CloudWallet({
walletAccessToken: '<WALLET_ACCESS_TOKEN>',
apiBaseUrl: 'https://cloudwallet.hovi.id',
});
const result = await wallet.resolveOpenIdUri({
protocol: 'openid',
credentialOfferUri: '<CREDENTIAL_OFFER_URI>',
});
Params
| Parameter | Type | Description |
|---|---|---|
| protocol | string (Required) | Use openid. |
| credentialOfferUri | string (Required) | The credential offer URI from the issuer, for example from a QR code. |
Preview credential offer
Shows what a credential offer contains, before the wallet accepts or declines it.
import { CloudWallet } from '@hovi/cloudwallet-sdk';
const wallet = new CloudWallet({
walletAccessToken: '<WALLET_ACCESS_TOKEN>',
apiBaseUrl: 'https://cloudwallet.hovi.id',
});
const result = await wallet.previewCredentialOffer({
protocol: 'openid',
credentialOfferUri: '<CREDENTIAL_OFFER_URI>',
});
Params
| Parameter | Type | Description |
|---|---|---|
| protocol | string (Required) | openid or didcomm. |
| credentialOfferUri | string (Optional) | EU Digital Identity: the credential offer URI. |
| credentialId | string (Optional) | cheqd and Indicio: the ID of the credential offer the wallet received. |
| connectionId | string (Optional) | cheqd and Indicio: the ID of the connection the offer came over. |
Accept credential offer
Accepts a credential offer and stores the credential in the wallet.
import { CloudWallet } from '@hovi/cloudwallet-sdk';
const wallet = new CloudWallet({
walletAccessToken: '<WALLET_ACCESS_TOKEN>',
apiBaseUrl: 'https://cloudwallet.hovi.id',
});
const result = await wallet.acceptCredentialOffer({
protocol: 'openid',
credentialOfferUri: '<CREDENTIAL_OFFER_URI>',
// Only if the issuer asked for a transaction code (PIN):
preAuthorizedFlowOptions: { transactionCode: '<TRANSACTION_CODE>' },
});
Params
| Parameter | Type | Description |
|---|---|---|
| protocol | string (Required) | openid or didcomm. |
| credentialOfferUri | string (Optional) | EU Digital Identity: the credential offer URI. |
| credentialId | string (Optional) | cheqd and Indicio: the ID of the credential offer to accept. |
| codeflow | string (Optional) | EU Digital Identity: the issuance flow of the offer. |
| preAuthorizedFlowOptions | { transactionCode: string } (Optional) | EU Digital Identity: the transaction code (PIN), if the issuer asked for one. |
| authorizationFlowOptions | object (Optional) | EU Digital Identity: options for the authorization code flow. |
The response contains the stored credential: its id, credentialType, attributes and issuanceDate.
Decline credential offer
Declines a credential offer. The credential isn't stored.
import { CloudWallet } from '@hovi/cloudwallet-sdk';
const wallet = new CloudWallet({
walletAccessToken: '<WALLET_ACCESS_TOKEN>',
apiBaseUrl: 'https://cloudwallet.hovi.id',
});
const result = await wallet.declineCredentialOffer({
protocol: 'didcomm',
credentialId: '<CREDENTIAL_ID>',
});
Params
| Parameter | Type | Description |
|---|---|---|
| protocol | string (Required) | openid or didcomm. |
| credentialId | string (Required) | The ID of the credential offer to decline. |
Delete credential
Deletes a stored credential from the wallet.
import { CloudWallet } from '@hovi/cloudwallet-sdk';
const wallet = new CloudWallet({
walletAccessToken: '<WALLET_ACCESS_TOKEN>',
apiBaseUrl: 'https://cloudwallet.hovi.id',
});
const result = await wallet.deleteCredential({
credentialId: '<CREDENTIAL_ID>',
});
Params
| Parameter | Type | Description |
|---|---|---|
| credentialId | string (Required) | The ID of the credential to delete. |
- This can't be undone.
Get credential offers
Lists the credential offers the wallet has received.
import { CloudWallet } from '@hovi/cloudwallet-sdk';
const wallet = new CloudWallet({
walletAccessToken: '<WALLET_ACCESS_TOKEN>',
apiBaseUrl: 'https://cloudwallet.hovi.id',
});
const result = await wallet.getCredentialOffers();
Get stored credentials
Lists the credentials stored in the wallet.
import { CloudWallet } from '@hovi/cloudwallet-sdk';
const wallet = new CloudWallet({
walletAccessToken: '<WALLET_ACCESS_TOKEN>',
apiBaseUrl: 'https://cloudwallet.hovi.id',
});
const result = await wallet.getStoredCredentials();