This package handles everything that has to do with the wallet in Hyperledger Aries.
import { EventHandler } from 'universal-ledger-agent'
import { WalletController } from '@ula-aca/wallet'
const walletController = new WalletController({
basePath: 'https://aca-py-api.com'
})
const eventHandler = new EventHandler([walletController])
List wallet DIDs
import { EventHandler, UlaResponse } from 'universal-ledger-agent'
import {
WalletController,
GetDidsMessage,
GetDidsResult,
WalletMessageTypes
} from '@ula-aca/wallet'
const walletController = new WalletController({
basePath: 'https://aca-py-api.com'
})
const eventHandler = new EventHandler([walletController])
const message: GetDidsMessage = {
type: WalletMessageTypes.GET_DIDS,
body: {
public: 'false',
did: 'WgWxqztrNooG92RXvxSTWv',
verkey: 'H3C2AVvLMv6gmMNam3uVAjZpfkcJCwDwnZn6z3wXmqPV'
}
}
eventHandler.processMsg(message, (response: UlaResponse) => {
if (response.statusCode < 200 || response.statusCode >= 300) {
// error
} else {
// response.body is response from /wallet/did api endpoint in aca-py
// https://ula-aca.github.io/aries-cloudagent-interface-javascript/#/wallet/get_wallet_did
const result: GetDidsResult = response.body
}
})
Create a local DID
import { EventHandler, UlaResponse } from 'universal-ledger-agent'
import {
WalletController,
CreateLocalDidMessage,
CreateLocalDidResult,
WalletMessageTypes
} from '@ula-aca/wallet'
const walletController = new WalletController({
basePath: 'https://aca-py-api.com'
})
const eventHandler = new EventHandler([walletController])
const message: CreateLocalDidMessage = {
type: WalletMessageTypes.CREATE_LOCAL_DID
}
eventHandler.processMsg(message, (response: UlaResponse) => {
if (response.statusCode < 200 || response.statusCode >= 300) {
// error
} else {
// response.body is response from /wallet/did/create POST api endpoint in aca-py
// https://ula-aca.github.io/aries-cloudagent-interface-javascript/#/wallet/post_wallet_did_create
const result: CreateLocalDidResult = response.body
}
})
Fetch the current public DID
import { EventHandler, UlaResponse } from 'universal-ledger-agent'
import {
WalletController,
FetchPublicDidMessage,
FetchPublicDidResult,
WalletMessageTypes
} from '@ula-aca/wallet'
const walletController = new WalletController({
basePath: 'https://aca-py-api.com'
})
const eventHandler = new EventHandler([walletController])
const message: FetchPublicDidMessage = {
type: WalletMessageTypes.FETCH_PUBLIC_DID
}
eventHandler.processMsg(message, (response: UlaResponse) => {
if (response.statusCode < 200 || response.statusCode >= 300) {
// error
} else {
// response.body is response from /wallet/did/public api endpoint in aca-py
// https://ula-aca.github.io/aries-cloudagent-interface-javascript/#/wallet/get_wallet_did_public
const result: FetchPublicDidResult = response.body
}
})
Assign the current public DID
import { EventHandler, UlaResponse } from 'universal-ledger-agent'
import {
WalletController,
AssignPublicDidMessage,
AssignPublicDidResult,
WalletMessageTypes
} from '@ula-aca/wallet'
const walletController = new WalletController({
basePath: 'https://aca-py-api.com'
})
const eventHandler = new EventHandler([walletController])
const message: AssignPublicDidMessage = {
type: WalletMessageTypes.ASSIGN_PUBLIC_DID,
body: {
did: 'WgWxqztrNooG92RXvxSTWv'
}
}
eventHandler.processMsg(message, (response: UlaResponse) => {
if (response.statusCode < 200 || response.statusCode >= 300) {
// error
} else {
// response.body is response from /wallet/did/public api endpoint in aca-py
// https://ula-aca.github.io/aries-cloudagent-interface-javascript/#/wallet/get_wallet_did_public
const result: AssignPublicDidResult = response.body
}
})
Get the tagging policy for a credential definition
import { EventHandler, UlaResponse } from 'universal-ledger-agent'
import {
WalletController,
GetTagPolicyMessage,
GetTagPolicyResult,
WalletMessageTypes
} from '@ula-aca/wallet'
const walletController = new WalletController({
basePath: 'https://aca-py-api.com'
})
const eventHandler = new EventHandler([walletController])
const message: GetTagPolicyMessage = {
type: WalletMessageTypes.GET_TAG_POLICY,
body: {
credential_definition_id: '3fa85f64-5717-4562-b3fc-2c963f66afa6'
}
}
eventHandler.processMsg(message, (response: UlaResponse) => {
if (response.statusCode < 200 || response.statusCode >= 300) {
// error
} else {
// response.body is response from /wallet/tag-policy/{id} api endpoint in aca-py
// https://ula-aca.github.io/aries-cloudagent-interface-javascript/#/wallet/get_wallet_tag_policy__id_
const result: GetTagPolicyResult = response.body
}
})
Set the tagging policy for a credential definition
import { EventHandler, UlaResponse } from 'universal-ledger-agent'
import {
WalletController,
SetTagPolicyMessage,
SetTagPolicyResult,
WalletMessageTypes
} from '@ula-aca/wallet'
const walletController = new WalletController({
basePath: 'https://aca-py-api.com'
})
const eventHandler = new EventHandler([walletController])
const message: SetTagPolicyMessage = {
type: WalletMessageTypes.SET_TAG_POLICY,
body: {
credential_definition_id: '3fa85f64-5717-4562-b3fc-2c963f66afa6',
taggables: ['score']
}
}
eventHandler.processMsg(message, (response: UlaResponse) => {
if (response.statusCode < 200 || response.statusCode >= 300) {
// error
} else {
// response.body is response from /wallet/tag-policy/{id} api endpoint in aca-py
// https://ula-aca.github.io/aries-cloudagent-interface-javascript/#/wallet/get_wallet_tag_policy__id_
const result: SetTagPolicyResult = response.body
}
})
For example usage see the examples/
directory.