Wallets
Install Dependency
Package: @affinidi-tdk/wallets-client
npm install @affinidi-tdk/wallets-client --saveCheck the latest version on the npm registry or view the source on GitHub.
Classes and Methods
Wallet API
Manages digital wallets for issuing and signing credentials.
createWallet
Creates a wallet by type.
Parameters
name, description, and didMethod ("key" or "web"). When didMethod is "web", didWebUrl is required.Example
import { WalletApi, Configuration, CreateWalletInput } from '@affinidi-tdk/wallets-client'
const api = new WalletApi(
new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)
// Create a did:key wallet
const request: CreateWalletInput = {
name: 'Wallet Name',
description: 'Description',
didMethod: 'key',
}
const { data } = await api.createWallet(request)
// Create a did:web wallet — didWebUrl is required
const { data: webWallet } = await api.createWallet({ didMethod: 'web', didWebUrl: 'https://<DOMAIN>' })deleteWallet
Deletes a wallet by ID.
Parameters
walletId
string
RequiredExample
import { WalletApi, Configuration } from '@affinidi-tdk/wallets-client'
const api = new WalletApi(
new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)
await api.deleteWallet('<WALLET_ID>')getWallet
Retrieves the details of a wallet.
Parameters
walletId
string
RequiredExample
import { WalletApi, Configuration } from '@affinidi-tdk/wallets-client'
const api = new WalletApi(
new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)
const { data } = await api.getWallet('<WALLET_ID>')listWallets
Returns the list of wallets in the project.
No parameters required.
Example
import { WalletApi, Configuration } from '@affinidi-tdk/wallets-client'
const api = new WalletApi(
new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)
const { data } = await api.listWallets()signCredential
Signs a credential using the wallet’s DID document.
Parameters
walletId
string
RequiredExample
import { WalletApi, Configuration, SignCredentialInputDto } from '@affinidi-tdk/wallets-client'
const api = new WalletApi(
new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)
const request: SignCredentialInputDto = {
unsignedCredential: {},
revocable: true,
unsignedCredentialParams: {
jsonLdContextUrl: '',
jsonSchemaUrl: '',
typeName: '',
credentialSubject: '',
holderDid: '',
expiresAt: '',
},
}
const { data } = await api.signCredential('<WALLET_ID>', request)signJwtToken
Signs a JSON Web Token using the wallet’s DID document.
Parameters
walletId
string
RequiredExample
import { WalletApi, Configuration, SignJwtToken } from '@affinidi-tdk/wallets-client'
const api = new WalletApi(
new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)
const request: SignJwtToken = {
header: {},
payload: {},
}
const { data } = await api.signJwtToken('<WALLET_ID>', request)updateWallet
Updates an existing wallet by ID.
Parameters
walletId
string
RequiredExample
import { WalletApi, Configuration, UpdateWalletInput } from '@affinidi-tdk/wallets-client'
const api = new WalletApi(
new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)
const request: UpdateWalletInput = {
name: '',
description: '',
}
const { data } = await api.updateWallet('<WALLET_ID>', request)createWalletKey
Adds a cryptographic key to an existing wallet.
Note: Multiple keys are only supported for
did:webwallets.
Parameters
walletId
string
RequiredExample
import { WalletApi, Configuration, CreateWalletKeyInput } from '@affinidi-tdk/wallets-client'
const api = new WalletApi(
new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)
const request: CreateWalletKeyInput = {
keyType: 'ed25519',
relationships: ['authentication', 'assertionMethod'],
}
const { data } = await api.createWalletKey('<WALLET_ID>', request)listWalletKeys
Retrieves all cryptographic keys associated with a wallet.
Note: Multiple keys are only supported for
did:webwallets.
Parameters
walletId
string
RequiredExample
import { WalletApi, Configuration } from '@affinidi-tdk/wallets-client'
const api = new WalletApi(
new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)
const { data } = await api.listWalletKeys('<WALLET_ID>')removeWalletKey
Removes a key from a wallet.
Note: Multiple keys are only supported for
did:webwallets.
Parameters
walletId
string
RequiredkeyId
string
Required"key-1").Example
import { WalletApi, Configuration } from '@affinidi-tdk/wallets-client'
const api = new WalletApi(
new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)
await api.removeWalletKey('<WALLET_ID>', 'key-1')updateWalletKey
Updates the verification relationships of an existing wallet key.
Note: Multiple keys are only supported for
did:webwallets.
Parameters
walletId
string
RequiredkeyId
string
Required"key-1").Example
import { WalletApi, Configuration, UpdateWalletKeyInput } from '@affinidi-tdk/wallets-client'
const api = new WalletApi(
new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)
const request: UpdateWalletKeyInput = {
relationships: ['authentication', 'keyAgreement'],
}
const { data } = await api.updateWalletKey('<WALLET_ID>', 'key-1', request)createServiceEndpoint
Adds a DID service endpoint to a wallet’s DID document.
Parameters
walletId
string
RequiredExample
import { WalletApi, Configuration, ServiceEndpointInput } from '@affinidi-tdk/wallets-client'
const api = new WalletApi(
new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)
const request: ServiceEndpointInput = {
url: 'https://example.com/messaging',
name: 'My Messaging Service',
serviceType: 'DIDCommMessaging',
}
const { data } = await api.createServiceEndpoint('<WALLET_ID>', request)listServiceEndpoints
Retrieves all service endpoints associated with a wallet.
Parameters
walletId
string
RequiredExample
import { WalletApi, Configuration } from '@affinidi-tdk/wallets-client'
const api = new WalletApi(
new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)
const { data } = await api.listServiceEndpoints('<WALLET_ID>')removeServiceEndpoint
Removes a service endpoint from a wallet’s DID document.
Parameters
walletId
string
RequiredserviceId
string
RequiredExample
import { WalletApi, Configuration } from '@affinidi-tdk/wallets-client'
const api = new WalletApi(
new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)
await api.removeServiceEndpoint('<WALLET_ID>', '<SERVICE_ID>')updateServiceEndpoint
Updates an existing service endpoint on a wallet.
Parameters
walletId
string
RequiredserviceId
string
RequiredExample
import { WalletApi, Configuration, UpdateServiceEndpointInput } from '@affinidi-tdk/wallets-client'
const api = new WalletApi(
new Configuration({ apiKey: authProvider.fetchProjectScopedToken.bind(authProvider) })
)
const request: UpdateServiceEndpointInput = {
name: 'Updated Service Name',
url: 'https://new-endpoint.example.com',
}
const { data } = await api.updateServiceEndpoint('<WALLET_ID>', '<SERVICE_ID>', request)Glad to hear it. Thanks for letting us know.
Sorry to hear that. Thanks for letting us know.