Wallets
Install Dependency
Package: @affinidi-tdk/wallets-client
npm install @affinidi-tdk/wallets-client --save
You can check the latest version of this module on the NPM repository or view the source code at the GitHub repository.
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.
Example
import { WalletApi, Configuration, CreateWalletInput } from '@affinidi-tdk/wallets-client'
// 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>"})
deleteWallet
Delete a Wallet by ID.
Parameters
walletId [String]
ID of the Wallet to delete.
Example
import { WalletApi, Configuration } from '@affinidi-tdk/wallets-client'
// 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)
getWallet
Retrieves the details of the Wallet.
Parameters
walletId [String]
ID of the Wallet to retrieve.
Example
import { WalletApi, Configuration } from '@affinidi-tdk/wallets-client'
// 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)
listWallets
Get the list of the Wallets.
Parameters
No Parameters Required
Example
import { WalletApi, Configuration } from '@affinidi-tdk/wallets-client'
// 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()
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.
Example
import { WalletApi, Configuration, SignCredentialInputDto } from '@affinidi-tdk/wallets-client'
// 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)
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.
Example
import { WalletApi, Configuration, SignJwtToken } from '@affinidi-tdk/wallets-client'
// 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)
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.
Example
import { WalletApi, Configuration, UpdateWalletInput } from '@affinidi-tdk/wallets-client'
// 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)
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.