Wallets

Manage Digital Wallet with Wallets Service.

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

Package: pkg:maven/com.affinidi.tdk/wallets.client

<dependency>
    <groupId>com.affinidi.tdk</groupId>
    <artifactId>wallets.client</artifactId>
    <version><version_number></version>
</dependency>

Check the Maven repository for the latest version of the package.

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;
import com.affinidi.tdk.authProvider.AuthProvider;
import com.affinidi.tdk.wallets.client.Configuration;
import com.affinidi.tdk.wallets.client.ApiClient;
import com.affinidi.tdk.wallets.client.apis.WalletApi;
import com.affinidi.tdk.wallets.client.auth.ApiKeyAuth;
import com.affinidi.tdk.wallets.client.models.CreateWalletInput;
import com.affinidi.tdk.wallets.client.models.CreateWalletResponse;
import com.affinidi.tdk.wallets.client.models.CreateWalletInput.DidMethodEnum;
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;
}
try {

    ApiClient defaultClient = Configuration.getDefaultApiClient();
    // Configure API key authorization: ProjectTokenAuth
    ApiKeyAuth ProjectTokenAuth = (ApiKeyAuth) defaultClient.getAuthentication("ProjectTokenAuth");
    ProjectTokenAuth.setApiKey(authProvider.fetchProjectScopedToken());

    WalletApi apiInstance = new WalletApi(defaultClient);

    CreateWalletInput requestInput = new CreateWalletInput()
            .name("Name")
            .description("Description")
            .didMethod(DidMethodEnum.KEY);

    CreateWalletResponse result = apiInstance.createWallet(requestInput);

    System.out.println(result.toString());

} catch (Exception e) {
    e.printStackTrace();
}

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;
import com.affinidi.tdk.authProvider.AuthProvider;
import com.affinidi.tdk.wallets.client.Configuration;
import com.affinidi.tdk.wallets.client.ApiClient;
import com.affinidi.tdk.wallets.client.apis.WalletApi;
import com.affinidi.tdk.wallets.client.auth.ApiKeyAuth;
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;
}
try {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    // Configure API key authorization: ProjectTokenAuth
    ApiKeyAuth ProjectTokenAuth = (ApiKeyAuth) defaultClient.getAuthentication("ProjectTokenAuth");
    ProjectTokenAuth.setApiKey(authProvider.fetchProjectScopedToken());

    String walletId = "<WALLET_ID>";

    apiInstance.deleteWallet(walletId);

} catch (Exception e) {
    e.printStackTrace();
}

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;
import com.affinidi.tdk.authProvider.AuthProvider;
import com.affinidi.tdk.wallets.client.Configuration;
import com.affinidi.tdk.wallets.client.ApiClient;
import com.affinidi.tdk.wallets.client.apis.WalletApi;
import com.affinidi.tdk.wallets.client.auth.ApiKeyAuth;
import com.affinidi.tdk.wallets.client.models.WalletDto;
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;
}
try {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    // Configure API key authorization: ProjectTokenAuth
    ApiKeyAuth ProjectTokenAuth = (ApiKeyAuth) defaultClient.getAuthentication("ProjectTokenAuth");
    ProjectTokenAuth.setApiKey(authProvider.fetchProjectScopedToken());

    WalletApi apiInstance = new WalletApi(defaultClient);

    String walletId = "<WALLET_ID>";

    WalletDto result = apiInstance.getWallet(walletId);

    System.out.println(result.toString());

} catch (Exception e) {
    e.printStackTrace();
}

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;
import com.affinidi.tdk.wallets.client.Configuration;
import com.affinidi.tdk.wallets.client.ApiClient;
import com.affinidi.tdk.wallets.client.apis.WalletApi;
import com.affinidi.tdk.wallets.client.auth.ApiKeyAuth;
import com.affinidi.tdk.wallets.client.models.WalletsListDto;
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;
}
try {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    // Configure API key authorization: ProjectTokenAuth
    ApiKeyAuth ProjectTokenAuth = (ApiKeyAuth) defaultClient.getAuthentication("ProjectTokenAuth");
    ProjectTokenAuth.setApiKey(authProvider.fetchProjectScopedToken());

    WalletApi apiInstance = new WalletApi(defaultClient);

    WalletsListDto result = apiInstance.listWallets(null);

    System.out.println(result.toString());

} catch (Exception e) {
    e.printStackTrace();
}

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;
import com.affinidi.tdk.authProvider.AuthProvider;
import com.affinidi.tdk.wallets.client.Configuration;
import com.affinidi.tdk.wallets.client.ApiClient;
import com.affinidi.tdk.wallets.client.apis.WalletApi;
import com.affinidi.tdk.wallets.client.auth.ApiKeyAuth;
import com.affinidi.tdk.wallets.client.models.SignCredentialInputDto;
import com.affinidi.tdk.wallets.client.models.UpdateWalletInput;
import com.affinidi.tdk.wallets.client.models.WalletDto;
import com.affinidi.tdk.wallets.client.models.SignCredentialInputDto.CredentialFormatEnum;
import com.affinidi.tdk.wallets.client.models.SignCredentialInputDtoUnsignedCredentialParams;
import com.affinidi.tdk.wallets.client.models.SignCredentialResultDto;
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;
}
try {

    ApiClient defaultClient = Configuration.getDefaultApiClient();
    // Configure API key authorization: ProjectTokenAuth
    ApiKeyAuth ProjectTokenAuth = (ApiKeyAuth) defaultClient.getAuthentication("ProjectTokenAuth");
    ProjectTokenAuth.setApiKey(authProvider.fetchProjectScopedToken());

    WalletApi apiInstance = new WalletApi(defaultClient);

    String walletId = "<WALLET_ID>";
    Object unsignedCredential = new Object();
    SignCredentialInputDto requestInput = new SignCredentialInputDto()
            .credentialFormat(CredentialFormatEnum.LDP_VC)
            .revocable(false)
            .unsignedCredential(unsignedCredential)
            .unsignedCredentialParams(new SignCredentialInputDtoUnsignedCredentialParams());

    SignCredentialResultDto response = apiInstance.signCredential(walletId, requestInput);

    System.out.println(response.toString());

} catch (Exception e) {
    e.printStackTrace();
}

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;
import com.affinidi.tdk.authProvider.AuthProvider;
import com.affinidi.tdk.wallets.client.Configuration;
import com.affinidi.tdk.wallets.client.ApiClient;
import com.affinidi.tdk.wallets.client.apis.WalletApi;
import com.affinidi.tdk.wallets.client.auth.ApiKeyAuth;
import com.affinidi.tdk.wallets.client.models.SignJwtToken;
import com.affinidi.tdk.wallets.client.models.SignJwtTokenOK;
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;
}
try {

    ApiClient defaultClient = Configuration.getDefaultApiClient();
    // Configure API key authorization: ProjectTokenAuth
    ApiKeyAuth ProjectTokenAuth = (ApiKeyAuth) defaultClient.getAuthentication("ProjectTokenAuth");
    ProjectTokenAuth.setApiKey(authProvider.fetchProjectScopedToken());

    WalletApi apiInstance = new WalletApi(defaultClient);

    String walletId = "<WALLET_ID>";

    SignJwtToken requestInput = new SignJwtToken()
            .header(new Object())
            .payload(new Object());

    SignJwtTokenOK response = apiInstance.signJwtToken(walletId, requestInput);

    System.out.println(response.toString());

} catch (Exception e) {
    e.printStackTrace();
}

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;
import com.affinidi.tdk.authProvider.AuthProvider;
import com.affinidi.tdk.wallets.client.Configuration;
import com.affinidi.tdk.wallets.client.ApiClient;
import com.affinidi.tdk.wallets.client.apis.WalletApi;
import com.affinidi.tdk.wallets.client.auth.ApiKeyAuth;
import com.affinidi.tdk.wallets.client.models.UpdateWalletInput;
import com.affinidi.tdk.wallets.client.models.WalletDto;
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;
}
try {

    ApiClient defaultClient = Configuration.getDefaultApiClient();
    // Configure API key authorization: ProjectTokenAuth
    ApiKeyAuth ProjectTokenAuth = (ApiKeyAuth) defaultClient.getAuthentication("ProjectTokenAuth");
    ProjectTokenAuth.setApiKey(authProvider.fetchProjectScopedToken());

    WalletApi apiInstance = new WalletApi(defaultClient);

    String walletId = "03707491e061e35e9756d4534c2edcb7";
    UpdateWalletInput requestInput = new UpdateWalletInput()
            .name("Name")
            .description("Description");

    WalletDto result = apiInstance.updateWallet(walletId, requestInput);

    System.out.println(result.toString());

} catch (Exception e) {
    e.printStackTrace();
}