Wallets
Supported Languages
Package: @affinidi-tdk/wallets-client
npm install @affinidi-tdk/wallets-client --save
Package: affinidi_tdk_wallets_client
pip install affinidi_tdk_wallets_client
Package: affinidi-tdk/affinidi-tdk-php
composer require affinidi-tdk/affinidi-tdk-php
Classes and Methods
Wallet API
Used to manage digital wallets for issuing credentials.
createWallet
Create a wallet by type.
Parameters
CreateWalletInput [Object]
JSON object to provide details for the wallet to create. See more here.
Module Imports
import { WalletApi, Configuration, CreateWalletInput } from '@affinidi-tdk/wallets-client'
import affinidi_tdk_wallets_client
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\WalletsClient;
Sample Codes
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const WalletApi = new WalletApi(authConfiguration)
const createWalletRequest : CreateWalletInput = {
name: "Wallet Name",
description: "Description",
didMethod: "key"
}
// create a did:key wallet
const { data } = await WalletApi.createWallet(createWalletRequest)
// create a did:web wallet - didWebUrl is mandatory
const { data } = await WalletApi.createWallet({didMethod: "web", didWebUrl: "https://<DOMAIN>"})
configuration = affinidi_tdk_wallets_client.Configuration()
# Pass the projectScopedToken generated from AuthProvider package
configuration.api_key['ProjectTokenAuth'] = projectScopedToken
with affinidi_tdk_wallets_client.ApiClient(configuration) as api_client:
api_instance = affinidi_tdk_wallets_client.WalletApi(api_client)
# create a did:key request json
new_wallet_json = {
"did_method": "key"
}
create_wallet_input = affinidi_tdk_wallets_client.CreateWalletInput.from_dict(new_wallet_json)
# create a did:key
api_response = api_instance.create_wallet(create_wallet_input=create_wallet_input)
# ===================================
# create a did:web request json - didWebUrl is mandatory
new_wallet_json = {
name: "Wallet Name",
description: "Description",
didMethod: "key"
}
create_wallet_input = affinidi_tdk_wallets_client.CreateWalletInput.from_dict(new_wallet_json)
# create a did:key
api_response = api_instance.create_wallet(create_wallet_input=create_wallet_input)
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new WalletsClient\Api\WalletApi(
new GuzzleHttp\Client(),
$config
);
try {
$request = array(
name: "Wallet Name",
description: "Description",
didMethod: "key"
);
$result = $apiInstance->createWallet($request);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
deleteWallet
Delete a Wallet by ID.
Parameters
walletId [String]
ID of the Wallet to delete.
Module Imports
import { WalletApi, Configuration } from '@affinidi-tdk/wallets-client'
import affinidi_tdk_wallets_client
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\WalletsClient;
Sample Codes
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const WalletApi = new WalletApi(authConfiguration)
const walletId= "<WALLET_ID-to-delete>"
const result = await WalletApi.deleteWallet(walletId)
configuration = affinidi_tdk_wallets_client.Configuration()
# Pass the projectScopedToken generated from AuthProvider package
configuration.api_key['ProjectTokenAuth'] = projectScopedToken
with affinidi_tdk_wallets_client.ApiClient(configuration) as api_client:
api_instance = affinidi_tdk_wallets_client.WalletApi(api_client)
wallet_id = "<WALLET_ID-to-delete>"
api_instance.delete_wallet(wallet_id)
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new WalletsClient\Api\WalletApi(
new GuzzleHttp\Client(),
$config
);
try {
$walletId= "<WALLET_ID-to-delete>";
$result = $apiInstance->deleteWallet($walletId);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
getWallet
Retrieves the details of the Wallet.
Parameters
walletId [String]
ID of the Wallet to retrieve.
Module Imports
import { WalletApi, Configuration } from '@affinidi-tdk/wallets-client'
import affinidi_tdk_wallets_client
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\WalletsClient;
Sample Codes
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const WalletApi = new WalletApi(authConfiguration)
const walletId= "<WALLET_ID>"
const result = await WalletApi.getWallet(walletId)
configuration = affinidi_tdk_wallets_client.Configuration()
# Pass the projectScopedToken generated from AuthProvider package
configuration.api_key['ProjectTokenAuth'] = projectScopedToken
with affinidi_tdk_wallets_client.ApiClient(configuration) as api_client:
api_instance = affinidi_tdk_wallets_client.WalletApi(api_client)
wallet_id = "<WALLET_ID>"
api_response = api_instance.get_wallet(wallet_id)
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new WalletsClient\Api\WalletApi(
new GuzzleHttp\Client(),
$config
);
try {
$walletId= "<WALLET_ID>";
$result = $apiInstance->getWallet($walletId);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
listWallets
Get the list of the Wallets.
Parameters
No Parameters Required
Module Imports
import { WalletApi, Configuration } from '@affinidi-tdk/wallets-client'
import affinidi_tdk_wallets_client
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\WalletsClient;
Sample Codes
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const WalletApi = new WalletApi(authConfiguration)
const result = await WalletApi.listWallets()
configuration = affinidi_tdk_wallets_client.Configuration()
# Pass the projectScopedToken generated from AuthProvider package
configuration.api_key['ProjectTokenAuth'] = projectScopedToken
with affinidi_tdk_wallets_client.ApiClient(configuration) as api_client:
api_instance = affinidi_tdk_wallets_client.WalletApi(api_client)
api_response = api_instance.list_wallets()
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new WalletsClient\Api\WalletApi(
new GuzzleHttp\Client(),
$config
);
try {
$result = $apiInstance->listWallets();
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
signCredential
Sign a credentials with the Wallet details (DID document).
Parameters
walletId [String]
ID of the Wallet used for signing the credential.
SignCredentialInputDto [Object]
JSON object to provide the credential data to sign. See more here.
Module Imports
import { WalletApi, Configuration, SignCredentialInputDto } from '@affinidi-tdk/wallets-client'
import affinidi_tdk_wallets_client
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\WalletsClient;
Sample Codes
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const WalletApi = new WalletApi(authConfiguration)
const walletId= "<WALLET_ID>"
const credentialRequest : SignCredentialInputDto = {
unsignedCredential: {},
revocable: true,
unsignedCredentialParams: {
jsonLdContextUrl: "",
jsonSchemaUrl: "",
typeName: "",
credentialSubject: "",
holderDid: "",
expiresAt: ""
}
}
const result = await WalletApi.signCredential(walletId, credentialRequest)
configuration = affinidi_tdk_wallets_client.Configuration()
# Pass the projectScopedToken generated from AuthProvider package
configuration.api_key['ProjectTokenAuth'] = projectScopedToken
with affinidi_tdk_wallets_client.ApiClient(configuration) as api_client:
api_instance = affinidi_tdk_wallets_client.WalletApi(api_client)
wallet_id = "<WALLET_ID>"
sign_credential_json = {
unsigned_credential: {},
revocable: true,
unsigned_credential_params: {
json_ld_context_url: "",
json_schema_url: "",
type_name: "",
credential_subject: "",
holder_did: "",
expires_at: ""
}
}
sign_credential_input_dto = affinidi_tdk_wallets_client.SignCredentialInputDto.from_dict()
api_response = api_instance.sign_credential(wallet_id, sign_credential_input_dto)
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new WalletsClient\Api\WalletApi(
new GuzzleHttp\Client(),
$config
);
try {
$walletId= "<WALLET_ID>";
$request = array(
"unsignedCredential" => array(),
"revocable" => true,
"unsignedCredentialParams" => array(
"jsonLdContextUrl" => "",
"jsonSchemaUrl" => "",
"typeName" => "",
"credentialSubject" => "",
"holderDid" => "",
"expiresAt" => ""
)
);
$result = $apiInstance->signCredential($walletId, $request);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
signJwtToken
Sign the JSON Web Token with the Wallet details (DID document).
Parameters
walletId [String]
ID of the Wallet used for signing the JWT.
SignCredentialInputDto [Object]
JSON object to provide the JWT data to sign. See more here.
Module Imports
import { WalletApi, Configuration, SignJwtToken } from '@affinidi-tdk/wallets-client'
import affinidi_tdk_wallets_client
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\WalletsClient;
Sample Codes
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const WalletApi = new WalletApi(authConfiguration)
const walletId= "<WALLET_ID>"
const signJwtTokenRequest : SignJwtToken = {
header: {},
payload: {}
}
const result = await WalletApi.signJwtToken(walletId, signJwtTokenRequest)
configuration = affinidi_tdk_wallets_client.Configuration()
# Pass the projectScopedToken generated from AuthProvider package
configuration.api_key['ProjectTokenAuth'] = projectScopedToken
with affinidi_tdk_wallets_client.ApiClient(configuration) as api_client:
api_instance = affinidi_tdk_wallets_client.WalletApi(api_client)
wallet_id = "<WALLET_ID>"
sign_jwt_token_request_json = {
header: {},
payload: {}
}
sign_jwt_token = affinidi_tdk_wallets_client.SignJwtToken.from_dict(sign_jwt_token_request_json)
try:
api_response = api_instance.sign_jwt_token(wallet_id, sign_jwt_token)
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new WalletsClient\Api\WalletApi(
new GuzzleHttp\Client(),
$config
);
try {
$walletId= "<WALLET_ID>";
$request = array(
header: {},
payload: {}
);
$result = $apiInstance->signJwtToken($walletId, $request);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
updateWallet
Update an existing Wallet by ID.
Parameters
walletId [String]
ID of the Wallet to update.
UpdateWalletInput [Object]
JSON object to provide details for the wallet to update. See more here.
Module Imports
import { WalletApi, Configuration, UpdateWalletInput } from '@affinidi-tdk/wallets-client'
import affinidi_tdk_wallets_client
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\WalletsClient;
Sample Codes
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const WalletApi = new WalletApi(authConfiguration)
const walletId= "<WALLET_ID>"
const updateWalletRequest : UpdateWalletInput = {
name: "",
description: ""
}
const result = await WalletApi.updateWallet(walletId, updateWalletRequest)
configuration = affinidi_tdk_wallets_client.Configuration()
# Pass the projectScopedToken generated from AuthProvider package
configuration.api_key['ProjectTokenAuth'] = projectScopedToken
with affinidi_tdk_wallets_client.ApiClient(configuration) as api_client:
api_instance = affinidi_tdk_wallets_client.WalletApi(api_client)
wallet_id = "<WALLET_ID>"
update_wallet_request_json = {
name: "",
description: ""
}
update_wallet_input = affinidi_tdk_wallets_client.UpdateWalletInput.from_dict(update_wallet_request_json)
try:
api_response = api_instance.update_wallet(wallet_id, update_wallet_input)
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new WalletsClient\Api\WalletApi(
new GuzzleHttp\Client(),
$config
);
try {
$walletId= "<WALLET_ID>";
$request = array(
name: "",
description: ""
);
$result = $apiInstance->updateWallet($walletId, $request);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
Revocation API
Used to retrieve and revoke issued credentials.
getRevocationListCredential
Retrieve the Revocation List of the Wallet. Used this to check if the Credential is revoked.
Parameters
listId [String]
ID of the Revocation List to retrieve.
walletId [String]
ID of the Wallet associated with the revocation list.
Module Imports
import { RevocationApi, Configuration } from '@affinidi-tdk/wallets-client'
import affinidi_tdk_wallets_client
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\WalletsClient;
Sample Codes
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const revokeApi = new RevocationApi(authConfiguration)
const listId = "<REVOC_LIST_ID>"
const walletId = "<WALLET_ID>"
const { data } = await revokeApi.getRevocationListCredential(listId, walletId)
configuration = affinidi_tdk_wallets_client.Configuration()
# Pass the projectScopedToken generated from AuthProvider package
configuration.api_key['ProjectTokenAuth'] = projectScopedToken
with affinidi_tdk_wallets_client.ApiClient(configuration) as api_client:
api_instance = affinidi_tdk_wallets_client.RevocationApi(api_client)
list_id = "<REVOC_LIST_ID>"
wallet_id = "<WALLET_ID>"
api_response = api_instance.get_revocation_list_credential(list_id, wallet_id)
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new WalletsClient\Api\RevocationApi(
new GuzzleHttp\Client(),
$config
);
try {
const listId = "<REVOC_LIST_ID>";
const walletId = "<WALLET_ID>";
$result = $apiInstance->getRevocationListCredential($listId, $walletId);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
revokeCredential
Used to revoke issued credential.
Parameters
walletId [String]
ID of the Wallet associated with the credential to revoke.
RevokeCredentialInput [Object]
JSON object to provide the credential info and reason for revoking the credential. See more here.
Module Imports
import { RevocationApi, Configuration, RevokeCredentialInput } from '@affinidi-tdk/wallets-client'
import affinidi_tdk_wallets_client
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\WalletsClient;
Sample Codes
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const revokeApi = new RevocationApi(authConfiguration)
const walletId = "<WALLET_ID>"
const revokeCredentialRequest : RevokeCredentialInput = {
revocationReason: "",
credentialId: ""
}
const { data } = await revokeApi.revokeCredential(walletId, revokeCredentialRequest)
configuration = affinidi_tdk_wallets_client.Configuration()
# Pass the projectScopedToken generated from AuthProvider package
configuration.api_key['ProjectTokenAuth'] = projectScopedToken
with affinidi_tdk_wallets_client.ApiClient(configuration) as api_client:
api_instance = affinidi_tdk_wallets_client.RevocationApi(api_client)
wallet_id = "<wallet_id>"
revoke_credential_json = {
revocationReason: "",
credentialId: ""
}
revoke_credential_input = affinidi_tdk_wallets_client.RevokeCredentialInput.from_dict(revoke_credential_json)
api_instance.revoke_credential(wallet_id, revoke_credential_input)
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new WalletsClient\Api\RevocationApi(
new GuzzleHttp\Client(),
$config
);
try {
$walletId = "<WALLET_ID>";
$request = array(
revocationReason: "",
credentialId: ""
);
$result = $apiInstance->revokeCredential($walletId, $request);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
getRevocationCredentialStatus
Retrieve the Revocation Status List as RevocationListCredential that must be a URL to the verifiable credential.
Parameters
projectId [String]
ID of the Project associated with the revocation list.
walletId [String]
ID of the Wallet associated with the revocation list.
statusId [String]
ID of the status of revocation list.
Module Imports
import { DefaultApi, Configuration } from '@affinidi-tdk/wallets-client'
import affinidi_tdk_wallets_client
require_once 'vendor/autoload.php';
use AffinidiTdk\Clients\WalletsClient;
Sample Codes
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const revokeApi = new DefaultApi(authConfiguration)
const projectId = "<PROJECT_ID>"
const walletId = "<WALLET_ID>"
const statusId = "<STATUS_ID>"
const { data } = await revokeApi.getRevocationCredentialStatus(projectId, walletId, statusId)
configuration = affinidi_tdk_wallets_client.Configuration()
# Pass the projectScopedToken generated from AuthProvider package
configuration.api_key['ProjectTokenAuth'] = projectScopedToken
with affinidi_tdk_wallets_client.ApiClient(configuration) as api_client:
api_instance = affinidi_tdk_wallets_client.DefaultApi(api_client)
project_id = "<PROJECT_ID>"
wallet_id = "<WALLET_ID>"
status_id = "<STATUS_ID>"
api_response = api_instance.get_revocation_credential_status(project_id, wallet_id, status_id)
$tokenCallback = [$authProvider, 'fetchProjectScopedToken'];
// Configure API key authorization: ProjectTokenAuth
$config = WalletsClient\Configuration::getDefaultConfiguration()->setApiKey('authorization', '', $tokenCallback);
$apiInstance = new WalletsClient\Api\DefaultApi(
new GuzzleHttp\Client(),
$config
);
try {
const projectId = "<REVOC_LIST_ID>";
const walletId = "<WALLET_ID>";
const statusId = "<WALLET_ID>";
$result = $apiInstance->getRevocationCredentialStatus($projectId, $walletId, $statusId);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling method: ', $e->getMessage(), PHP_EOL;
}
Glad to hear it! Please tell us how we can improve more.
Sorry to hear that. Please tell us how we can improve.
Thank you for sharing your feedback so we can improve your experience.