Mobile SDK
React-Native Mobile SDK to build SSI powered identity apps & edge wallets
Installing
npm install @credebl/ssi-mobile
# or
yarn add @credebl/ssi-mobile
# or
pnpm add @credebl/ssi-mobilePeer Dependencies
We also need to add the peer dependencies of this package to app.
"dependencies": {
...
"@hyperledger/anoncreds-react-native": "^0.1.0",
"@hyperledger/aries-askar-react-native": "^0.1.1",
"@hyperledger/indy-vdr-react-native": "^0.1.0",
}Usage
import { useAdeyaAgent } from '@credebl/ssi-mobile'
const { agent } = useAdeyaAgent()API
Agent
initializeAgent - Initialize the agent with the given
ConfigandAgent Modules. This includes all the config related to the wallet details and label.
import { initializeAgent } from '@credebl/ssi-mobile'
const config: InitConfig = {
label: 'Alice Wallet',
walletConfig: {
id: 'alice-wallet',
key: 'alice-wallet-key'
},
logger: new ConsoleLogger(LogLevel.debug),
autoUpdateStorageOnStartup: true
}
const agent = await initializeAgent({
agentConfig: config,
modules: getAgentModules(mediatorUrl, indyLedgers)
})getAgentModules - Get the default agent modules which requires
mediatorURLandindyLedgers
import { getAgentModules } from '@credebl/ssi-mobile'
const modules = getAgentModules(mediatorUrl, indyLedgers)AdeyaAgent - The agent instance type which helps in typing our agent object.
import { AdeyaAgent } from '@credebl/ssi-mobile'Wallet
isWalletPinCorrect - Check if the wallet pin is correct.
import { isWalletPinCorrect } from '@credebl/ssi-mobile'
const isCorrect = await isWalletPinCorrect(walletConfig)exportWallet - Export the wallet and pass export config which includes
backupKeyandpathwhere we want to export our wallet.
import { exportWallet } from '@credebl/ssi-mobile'
await exportWallet(agent, exportConfig)importWalletWithAgent - Import the wallet and start the agent with
importConfigwhich includeskeyandpathfrom where wallet can be imported
import { importWalletWithAgent } from '@credebl/ssi-mobile'
const agent = await importWalletWithAgent({
importConfig,
agentConfig,
modules
})Connections
createLegacyInvitation - Create a legacy invitation which use the connection v1 protocol.
import { createLegacyInvitation } from '@credebl/ssi-mobile'
const connection = await createLegacyInvitation(agent, domain, config)createLegacyConnectionlessInvitation - Create a legacy connectionless invitation.
import { createLegacyConnectionlessInvitation } from '@credebl/ssi-mobile'
const connection = await createLegacyConnectionlessInvitation(agent, config)createInvitation - Create an Out-of-band invitation.
import { createInvitation } from '@credebl/ssi-mobile'
const connection = await createInvitation(agent, domain, config)acceptInvitation - Accept an invitation.
import { acceptInvitation } from '@credebl/ssi-mobile'
const connection = await acceptInvitation(agent, invitation, config)parseInvitationFromUrl - Parse an invitation from a url.
import { parseInvitationFromUrl } from '@credebl/ssi-mobile'
const invitation = await parseInvitationFromUrl(agent, invitationUrl)acceptInvitationFromUrl - Accept an invitation from a url.
import { acceptInvitationFromUrl } from '@credebl/ssi-mobile'
const connection = await acceptInvitationFromUrl(agent, invitationUrl, config)getAllConnections - Get all connections.
import { getAllConnections } from '@credebl/ssi-mobile'
const connections = await getAllConnections(agent)getConnectionById - Get a connection by id.
import { getConnectionById } from '@credebl/ssi-mobile'
const connection = await getConnectionById(agent, connectionId)findConnectionById - Find a connection by id.
import { findConnectionById } from '@credebl/ssi-mobile'
const connection = await findConnectionById(agent, connectionId)findOutOfBandRecordById - Find an out of band record by id.
import { findOutOfBandRecordById } from '@credebl/ssi-mobile'
const record = await findOutOfBandRecordById(agent, recordId)findByReceivedInvitationId - Find an out of band record by invitation id.
import { findByReceivedInvitationId } from '@credebl/ssi-mobile'
const record = await findByReceivedInvitationId(agent, receivedInvitationId)deleteConnectionRecordById - Delete a connection record by id.
import { deleteConnectionRecordById } from '@credebl/ssi-mobile'
await deleteConnectionRecordById(agent, connectionId)deleteOobRecordById - Delete a out-of-band record by id.
import { deleteOobRecordById } from '@credebl/ssi-mobile'
await deleteOobRecordById(agent, outOfBandId)Credentials
getAllCredentialExchangeRecords - Get all credential exchange records.
import { getAllCredentialExchangeRecords } from '@credebl/ssi-mobile'
const records = await getAllCredentialExchangeRecords(agent)getFormattedCredentialData - Retrieves the formatted data for a given credential record ID.
import { getFormattedCredentialData } from '@credebl/ssi-mobile'
const formattedData = await getFormattedCredentialData(agent, credentialRecordId)acceptCredentialOffer - Accept a credential offer.
import { acceptCredentialOffer } from '@credebl/ssi-mobile'
const credential = await acceptCredentialOffer(agent, options)updateCredentialExchangeRecord - Update a credential exchange record. This can be used to add or update the metadata of credential exchange record.
import { updateCredentialExchangeRecord } from '@credebl/ssi-mobile'
await updateCredentialExchangeRecord(agent, credentialRecord)declineCredentialOffer - Decline a credential offer.
import { declineCredentialOffer } from '@credebl/ssi-mobile'
const record = await declineCredentialOffer(agent, credentialRecordId)deleteCredentialExchangeRecordById - Delete a credential exchange record by id.
import { deleteCredentialExchangeRecordById } from '@credebl/ssi-mobile'
await deleteCredentialExchangeRecordById(agent, credentialRecordId, options)sendCredentialProblemReport - Send a credential problem report.
import { sendCredentialProblemReport } from '@credebl/ssi-mobile'
const record = await sendCredentialProblemReport(agent, options)getW3cCredentialRecordById - Get a W3C credential record by id.
import { getW3cCredentialRecordById } from '@credebl/ssi-mobile'
const record = await getW3cCredentialRecordById(agent, credentialRecordId)getAllW3cCredentialRecords - Get all W3C credential records.
import { getAllW3cCredentialRecords } from '@credebl/ssi-mobile'
const records = await getAllW3cCredentialRecords(agent)Proofs
getProofFormatData - Get proof format data.
import { getProofFormatData } from '@credebl/ssi-mobile'
const data = await getProofFormatData(agent, proofRecordId)getCredentialsForProofRequest - Get credentials for a proof request.
import { getCredentialsForProofRequest } from '@credebl/ssi-mobile'
const credentials = await getCredentialsForProofRequest(agent, options)selectCredentialsForProofRequest - Select credentials for a proof request.
import { selectCredentialsForProofRequest } from '@credebl/ssi-mobile'
const credentials = await selectCredentialsForProofRequest(agent, options)getProofRequestAgentMessage - Get a proof request agent message.
import { getProofRequestAgentMessage } from '@credebl/ssi-mobile'
const message = await getProofRequestAgentMessage(agent, proofRecordId)createProofRequest - Create a proof request.
import { createProofRequest } from '@credebl/ssi-mobile'
const proofRequest = await createProofRequest(agent, options)requestProof - Request a proof.
import { requestProof } from '@credebl/ssi-mobile'
const proof = await requestProof(agent, options)updateProofRecord - Update a proof record.
import { updateProofRecord } from '@credebl/ssi-mobile'
await updateProofRecord(agent, proofRecord)acceptProofRequest - Accept a proof request.
import { acceptProofRequest } from '@credebl/ssi-mobile'
const proof = await acceptProofRequest(agent, options)declineProofRequest - Decline a proof request.
import { declineProofRequest } from '@credebl/ssi-mobile'
const proof = await declineProofRequest(agent, options)sendProofProblemReport - Send a proof problem report.
import { sendProofProblemReport } from '@credebl/ssi-mobile'
const proof = await sendProofProblemReport(agent, options)BasicMessages
sendBasicMessage - Send a basic message.
import { sendBasicMessage } from '@credebl/ssi-mobile'
const record = await sendBasicMessage(agent, options)PushNotifications
setPushNotificationDeviceInfo - Set the push notification device info.
import { setPushNotificationDeviceInfo } from '@credebl/ssi-mobile'
await setPushNotificationDeviceInfo(agent, options)Hooks
useAdeyaAgent - React hooks to get the agent instance.
import { useAdeyaAgent } from '@credebl/ssi-mobile'
const { agent } = useAdeyaAgent()Last updated
