Wallets

Manage Digital Wallet with Wallets Service.

Install Dependency

Package: @affinidi-tdk/wallets-client

npm install @affinidi-tdk/wallets-client --save

Check 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

request CreateWalletInput Required
Details of the wallet to create, including 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 Required
ID of the wallet to delete.

Example

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 Required
ID of the wallet to retrieve.

Example

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 Required
ID of the wallet used to sign the credential.
request SignCredentialInputDto Required
Credential data to sign.

Example

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 Required
ID of the wallet used to sign the JWT.
request SignJwtToken Required
JWT header and payload data to sign.

Example

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 Required
ID of the wallet to update.
request UpdateWalletInput Required
Updated wallet details.

Example

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:web wallets.

Parameters

walletId string Required
ID of the wallet to add the key to.
request CreateWalletKeyInput Required
Key type and verification relationships to assign.

Example

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:web wallets.

Parameters

walletId string Required
ID of the wallet.

Example

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:web wallets.

Parameters

walletId string Required
ID of the wallet.
keyId string Required
Wallet-scoped key identifier (e.g. "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:web wallets.

Parameters

walletId string Required
ID of the wallet.
keyId string Required
Wallet-scoped key identifier (e.g. "key-1").
request UpdateWalletKeyInput Required
Updated verification relationships for the key.

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 Required
ID of the wallet.
request ServiceEndpointInput Required
Service endpoint details including URL, name, and service type.

Example

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 Required
ID of the wallet.

Example

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 Required
ID of the wallet.
serviceId string Required
ID of the service endpoint to remove.

Example

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 Required
ID of the wallet.
serviceId string Required
ID of the service endpoint to update.
Updated service endpoint details.

Example

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)