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

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
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: "",
    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 = {
        "did_method": "key"
        "did_web_url": "https://<DOMAIN>"
    }

    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)

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
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)

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
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)

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
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()

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
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)

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
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)

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
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)

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
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)

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
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)