Introduction
To fully integrate with the wallet and manage all interactions between the app and the wallet service, you need to implement the following callback handlers. These callbacks allow your app to respond to different stages of the wallet flow, incoming messages, user approvals, and system requests. Each callback is invoked by the SDK to notify the app about specific events or request app-level decisions. Proper implementation of these handlers ensures smooth communication, UI updates, and secure user interactions.
NoteThese functions do not provide any UI elements or functionality.
The developer must implement the UI elements and functionality themselves. (examples included)
The callbackHandlers
object encapsulates the logic needed to handle different types of incoming messages or events, including credential offers, proof requests, notifications, and data messages. This ensures a modular and maintainable codebase where each callback can be updated independently.
This should be added inside agent config object, like this:
//initialize it here:
const callbackHandlers = {}; //empty object for now
const agentConfig: AgentConfig = {
encryptionKey: DB_ENCRYPTION_KEY,
home: agentInfo,
webSocketSettings: {
idleTimeoutSeconds: 180,
scanIntervalSeconds: 5,
},
autoProcessIncomingMessages: false,
userInfo: {
name: firstName + " " + lastName,
},
callbackHandlers: callbackHandlers, // Here
activityCallbackHandlers: activityCallbackHandlers,
eventHandlers: {},
};
Example
const callbackHandlers: CallbackHandlers = {
actionMessageCallback: async (model: any) => {},
credentialOfferCallback: async (
credentialOffer: CredentialOfferCallbackModel
) => {},
addContactApprovalCallback: async (model: any) => {},
presentationRequestCallback: async (proofItem: PresentationRequest) => {},
generalMessageCallback: async (result: GeneralMessageModel) => {},
onMessageReceivedCallback: (notifications: Notification[]) => {},
dataMessageCallback: async (model: any) => {},
getMyIpAddressCallback: async (model: any) => {},
};