All pages
Powered by GitBook
1 of 1

Loading...

Proven Mobile SDK

Proven Mobile SDK Documentation

The Indicio Holdr SDK (Software Development Kit) supports Android and iOS platforms and provides holder capabilities that are compatible with many Aries protocols. Consumption of the Holdr SDK will allow an application to have its own Aries Askar wallet for holding digital credentials that conform to the Anoncreds specification, communicate with ledgers through IndyVDR, and generate zero trust proofs for information verification through Anoncreds-RS.

Supported Aries protocols:

  • Did Exchange 1.0

  • Out Of Band 1.1

  • Coordinate Mediation 1.0

  • Pickup 2.0

  • Issue Credential 2.0

  • Present Proof 2.0

  • Did:Peer:1

  • Did:Peer:2

  • Did:Key

  • Anoncreds

Sudo Typescript syntax is used to express the API. Any parameter that could be undefined is optional in Kotlin and React Native. Due to limitations with Swift code generation, not all Swift functions have default parameters when a value is optional and will need to have nil provided explicitly. A function using the await keyword is async in React Native and Swift and suspended in Kotlin.

Starts the agent and connects to the default mediator if a mediation configuration is provided.

Stops all even listeners and websockets and properly closes the wallet’s database files, so the agent can be used later.

Deletes the agent and all data associated with it, essentially resetting the wallet.

Sends a didExchange request to the agent associated with the provided out-of-band record.

Completes the didExchange handshake by sending a complete message to the agent associated with the provided didExchangeId.

Used when the auto-accept connection is disabled on the agent. This function is used to complete the started didExchange process once an out-of-band invitation has been processed, and a didExchange record is created but not auto-accepted.

Used to send a trust ping to another agent to ensure we can reach the agent.

Waits until the provided didExchangeId reaches a state of Done or until the provided timeout is reached.

Retrieves all didExchange records.

Finds all records that have tags matching the given query.

Retrieves the record with the provided ID or throws a RecordNotFoundError.

Finds the record with the given ID or returns null if not found.

Deletes the record with the given ID or throws RecordNotFoundError if it does not exist.

Finds all records associated with the given out-of-band ID.

Finds the record associated with the provided Did.

Finds the record whose invitation contained the provided Did.

Creates an out-of-band invitation and corresponding out-of-band record that is returned.

Parses a URL encoded invitation into an OutOfBandInvitationMessage.

Processes the provided invitation and potentially starts or completes didExchange protocol.

Processes an invitation where the invitation message is not present and the agent is implicitly invited.

Accepts the invitation of an existing out-of-band record. It is not commonly used.

Finds the out-of-band record with the corresponding invitation ID, or returns null.

Finds the out-of-band record that corresponds to the invitation with the given ID that we have created, or returns null.

Retrieves all of the out-of-band records held by the agent.

Retrieves all out-of-band records that match the provided query.

Retrieves the record with the provided ID or throws RecordNotFoundError.

Finds the record with the given ID or returns null.

Deletes the record with the given ID or throws RecordNotFoundError if no such record exists.

Finds all credentials whose schema ID matches the provided schema ID.

Sends a proposal to the connection with the associated didExchangeId that we want the specified credential from.

Accepts the offer associated with the provided credential exchange record.

Accepts the issue credential and saves it to the agent's wallet.

Finds the record with the given ID or returns null.

Finds all credentials whose exchange state matches the provided state.

Finds all records whose state matches the given state and came from the connection associated with the given didExchangeId.

Retrieves all of the credentialExchangeRecords.

Finds the credential exchange record that has matching threadId and didExchangeId (optional) or returns null.

Retrieves the credential exchange record that has matching threadId and didExchangeId (optional): otherwise it throws RecordNotFoundError.

Attempts to auto-accept the proof with the provided ID from the provided didExchange connection, it will throw ProvenError if the proof cannot be satisfied.

Accepts the given proof using the provided credential selections, it will throw ProvenError if the credential selection is invalid or insufficient.

Retrieves a mapping of proof requests to valid credentials for the request that require further selection. Throws RecordNotFoundError if the proof cannot be satisfied with the agent's current credentials.

Finds credentials that satisfy the proof request and automatically selects valid credentials if there are multiple options. Throws RecordNotFoundError if the proof cannot be satisfied with the agent's current credentials.

Retrieves the proof records for a given connection from the didExchange ID.

Starts or resumes the mediation to the default mediator. Called in agent.start by default.

Instructs the agent to attempt to pick up messages from the provided mediator record or the default mediator if not provided.

Finds the default mediator if one is set, otherwise returns null.

Finds the default mediator’s record. If the default mediator is found but not granted, this will throw ProvenError.

Sets the default mediator.

Requests mediation from the given didExchange connection.

Retrieves the mediation record with the provided didExchange ID or throws RecordNotFoundError.

Finds the mediation record with the given didExchange ID or returns null if not found.

Retrieves all of the meditation records.

Finds the didExchange record for the default mediator or returns null if not found

Attempts to complete the mediation request from the provided didExchange record in the given time. If it doesn’t complete, it will throw CancellatinException.

Retrieves the routing for this mediator. This is not available in React Native.

Sends a basic message to another connection.

Finds a basic message record by ID.

Retrieves all basic messages.

Finds all basic messages with matching comments.

Finds all basic messages from the recipient.

Finds all basic messages that match the role.

React Native events take a callback function and return a function to remove the callback.

The events that can have a handler registered are:

  • registerDidExchangeHandler

  • registerProofsHandler

  • registerCredentialsHandler

Directly retrieve the event flow and use Kotlin's flow API using the events API. There is also a provided co-routine context on the events object.

The events that can be retrieved in Kotlin are the following:

  • getDidExchangeEvents

  • getAgentEvents

  • getCredentialEvents

The following methods wrap events so you can easily listen to them without a third-party library or if you are using Objective-C:

  • onDidExchangeStateChanged

  • onCredentialStateChanged

  • onTrustPingEvent

Swift

registerAgentHandler
  • registerBasicMessageHandler

  • registerRecordHandler

  • registerWebSocketHandler

  • getEventBusEvents (Record update events)
  • getMessageEvents (Events for all messages)

  • getProofEvents

  • getBasicMessageEvents

  • getTrustPingEvents

  • getWebSocketEvents

  • onAgentEvent
  • onRecordEvent

  • onProofEvent

  • onWebsocketEvent

  • onBasicMessageEvent

  • await agent.start(
        timeout: 10_000 // Optional -- time limit in MS to connect to mediator
    )
    await agent.stop()
    await agent.delete()
    const didExchangeRecord = await agent.didExchange.acceptOutOfBandInvitation(
        outOfBandRecord: OutOfBandRecord, // Record id (String) in React Native
        autoAcceptConnection: Boolean | undefined,
        label: String | undefined,
        alias: String | undefined,
        routingParam: Routing | undefined // Not available in React Native
    )
    const didExchangeRecord = await agent.didExchange.acceptResponse(
        didExchangeId: String
    )
    const didExchangeRecord = await agent.didExchange(
        didExchangeId: String,
        outOfBandId: String,
        routingParam: Routing | undefined // Not available in React Native
    )
    const trustPingMessage = await agent.didExchange.sendPing(
        exchangeId: String,
        responseRequested: Boolean,
        returnRouting: Boolean
    )
    const didExchangeStateChangedEvent: DidExchangeStateChangedEvent? = await agent.didExchange.returnWhenIsConnected(
        didExchangeId: String,
        timeOutMs: Number | Long
    )
    const records: Array<DidExchangeRecord> = await agent.didExchange.getAll()
    const records: Array<DidExchangeRecord> = await agent.didExchange.findAllByQuery(
        query: Query // Record<String, String> in React Native. Malformed Query will throw
    )
    const record = await agent.didExchange.getById(
        didExchangeId: String
    )
    const record: DidExchangeRecord? = await agent.didExchange.findById(
        didExchangeId: String
    )
    await agent.didExchange.deleteById(
        didExchangeId: String
    )
    const records: Array<DidExchangeRecord> = await agent.didExchange.getAllByOutOfBandId(
      outOfBandId: String
    )
    const record: DidExchangeRecord? = await agent.didExchange.findByDid(
        did: String
    )
    const record: DidExchangeRecord? = await agent.didExchange.findByInvitationDid(
        did: String
    )
    const record = await agent.outOfBand.createInvitation(
        label: String | undefined,
        alias: String | undefined,
        goalCode: String | undefined,
        goal: String | undefined,
        handShake: Boolean | undefined,
        messages: Array<BaseMessage> | undefined,
        multiUseInvitation: Boolean | undefined,
        autoAcceptConnection: Boolean | undefined,
        routingParam: Routing | undefined, // Not available in React Native
        appendedAttachment: Array<Attachment> | undefined
    )
    const message = agent.outOfBand.parseInvitation(
        invitationUrl: String
    )
    const invitationResponse = await agent.outOfBand.receiveInvitation(
        invitation: OutOfBandInvitationMessage,
        label: String | undefined,
        alias: String | undefined,
        autoAcceptConnection: Boolean | undefined,
        reuseConnection: Boolean | undefined,
        routingParam: Routing | undefined, // Not available in React Native
        acceptInvitationTimeOutMs = Number | Long | undefined
    )
    const invitationResponse = await agent.outOfBand.receiveImplicitInvitation(
        label: String | undefined,
        alias: String | undefined,
        autoAcceptConnection: Boolean | undefined,
        reuseConnection: Boolean | undefined,
        routingParam: Routing | undefined, // Not available in React Native
        acceptInvitationTimeOutMs: Number | Long | null,
        did: String,
        handShakeProtocol: Array<String> | null
    )
    const invitationResponse = await agent.outOfBand.acceptInvitation(
        outOfBand: String,
        autoAcceptConnection: Boolean,
        reuseConnection: Boolean,
        label: String,
        alias: String | null,
        routingParam: Routing | null,
        timeOutMs: Number | undefined
    )
    const record: OutOfBandRecord? = await agent.outOfBand.findByReceivedInvitationId(
        receivedInvitationId: String
    )
    const record: OutOfBandRecord? = await agent.outOfBand.findByCreatedInvitationId(
        createdInvitationId: String
    )
    const records: Array<OutOfBandRecord> = await agent.outOfBand.getAll()
    const records: Array<OutOfBandRecord> = await agent.outOfBand.getAllByQuery(
        query: Query // Record<String, String> in React Native. Malformed Query will throw
    )
    const record = await agent.outOfBand.getById(
        outOfBandId: String
    )
    const record: OutOfBandRecord? = await agent.outOfBand.findById(
        outOfBandId: String
    )
    await agent.outOfBand.deleteById(
        outOfBandId: String
    )
    const records: Array<CredentialRecord> = await agent.credentials.findAllCredentialsBySchemaId(
        schemaId: String
    )
    const records: Array<CredentialRecord> = await agent.credentials.findAllCredentialsBySchemaId(
        schemaId: String
    )
    const record = await agent.credentials.acceptOffer(
        credentialExchangeId: String,
        autoAcceptCredential: Boolean | undefined,
        comment: String | null | undefined
    )
    const record = agent.credentials.acceptCredential(
        credentialExchangeId: String
    )
    const record: CredentialExchangeRecord? = await agent.credentials.findByRecordId(
        credentialExchangeId: String
    )
    const records: Array<CredentialExchangeRecord> = await agent.credentials.findAllByState(
        state: CredentialState
    )
    const records: Array<CredentialExchangeRecord> = await agent.credentials.findAllByStateAndDidExchangeId(
        state: CredentialState,
        didExchangeId: String
    )
    const records: Array<CredentialExchangeRecord> = await agent.credentials.getAll()
    const record = await agent.credentials.findByThreadIdAndDidExchangeId(
        threadId: String,
        didExchangeId: String | null
    )
    const record = await agent.proofs.autoAcceptProof(
        proofId: String,
        exchangeId: String
    )
    const record = await agent.proofs.acceptProof(
        proofData: PresentationData
    )
    const creds = await agent.proofs.getCredentialsForProofRequest(
        proofId: String,
        exchangeId: String,
        nonRevoked: Boolean | undefined
    )
    const creds = await agent.proofs.autoSelectCredentialsForProofRequest(
        proofId: String,
        exchangeId: String,
        nonRevoked: Boolean | undefined
    )
    const records: Array<ProofRecord> = await agent.proofs.getProofRequestsForConnection(
        didExchangeId: String
    )
    await agent.routing.initialize()
    await agent.routing.initiateMessagePickup(
        mediator: MediationRecord | null | undefined // Record id is used in React Native
    )
    const record: MediationRecord? = await agent.routing.findDefaultMediator()
    const record: MediationRecord? = await agent.routing.discoverMediation()
    const record = await agent.routing.setDefaultMediator(
        mediation: MediationRecord | String // Provide the record or the record id. React native only uses Id
    )
    const record = await agent.routing.requestMediation(
        didExchange: DidExchangeRecord | String // Provide the record or the record id. React native only uses Id
    )
    const record = await agent.routing.getByExchangeId(
        exchangeId: String
    )
    const record: MediationRecord? = await agent.routing.findByExchangeId(
        exchangeId: String
    )
    const records: Array<MediationRecord> = await agent.routing.getMediators()
    const record: DidExchangeRecord? = await agent.routing.findDefaultMediatorExchange()
    const record: MediationRecord? = await agent.routing.provision(
        didExchangeRecord: DidExchangeRecord,
        timeOutMs: Number | Long | undefined
    )
    const routing = await agent.routing.getRouting(
        mediatorId: String,
        useDefaultMediator: Boolean | undefined
    )
    const sentMessageRecord = await agent.basicMessages.send(
        didExchangeId: String, // ID of target
        content: String, // Message content to be sent
        locale: String = "en", // L10nDecorator version (defaults to "en")
        comment: String? // Comment on message
    )
    const basicMessage = await agent.basicMessages.findById(
        basicMessageRecordId: String // Record ID to be retrieved
    )
    const basicMessages = await agent.basicMessages.getAll()
    const basicMessages = await agent.basicMessages.findByComment(
        comment: String // Comment to search for
    )
    const basicMessages = await agent.basicMessages.findByDidExchangeId(
        didExchangeId: String // Exchange ID to look for
    )
    const basicMessages = await agent.basicMessages.findByRole(
        role: BasicMessageRole // Role to look for
    )
    const remove = agent.events.registerDidExchangeHandler((event) => {
        console.log("Got a didExchange event")
    })
    
    remove() // cancels the event callback
    / May not be defined if there were issues with agent initialization
    val didExchange: DidExchangeEvents? = agent.events.getDidExchangeEvents()
    
    agent.events.scope.launch {
        didExchange.events.onEach{
            println("Got a didExchange event")
        }.collect() // Make sure to call collect or events will not be processed
    }
    
    let removeListener = agent.events.onDidExchangeStateChanged { event in
      // Handle DidExchangeStateChangedEvent here
    }
    // Remove listener when no longer needed
    removeListener(nil)

    Supported DID methods:

    Supported credential formats:

    API Overview

    Agent

    async agent.start(): void

    async agent.stop(): void

    async agent.delete(): void

    DidExchange

    async didExchange.acceptOutOfBandInvitation(): DidExchangeRecord

    async didExchange.acceptResponse(): DidExchangeRecord

    async didExchange.requestConnection(): DidExchangeRecord

    async didExchange.sendPing(): TrustPingMessage

    async didExchange.returnWhenIsConnected(): DidExchangeStateChangedEvent?

    async didExchange.getAll(): Array[DidExchangeRecord]

    async didExchange.findAllByQuery(): Array[DidExchangeRecord]

    async didExchange.getById(): DidExchangeRecord

    async didExchange.findById(): DidExchangeRecord?

    async didExchange.deleteById(): void

    async didExchange.findAllByOutOfBandId(): Array[DidExchangeRecord]

    async didExchange.findByDid(): DidExchangeRecord?

    async didExchange.findByInvitationDid(): DidExchangeRecord?

    Out Of Band

    async outOfBand.createInvitation(): OutOfBandRecord

    outOfBand.parseInvitation(): OutOfBandInvitationMessage

    async outOfBand.receiveInvitation(): AcceptInvitationResponse

    async outOfBand.receiveImplicitInvitation(): AcceptInvitationResponse

    async outOfBand.acceptInvitation(): AcceptInvitationResponse

    async outOfBand.findByInvitationId(): OutOfBandRecord?

    async outOfBand.findByCreatedInvitationId(): OutOfBandRecord?

    async outOfBand.getAll(): Array[OutOfBandRecord]

    async outOfBand.getAllByQuery(): Array[OutOfBandRecord]

    async outOfBand.getById(): OutOfBandRecord

    async outOfBand.findById(): OutOfBandRecord?

    async outOfBand.deleteById(): void

    Credentials

    async credentials.findAllCredentialsBySchemaId(): Array[CredentialRecord]

    async credentials.proposeCredential(): CredentialExchangeRecord

    async credentials.acceptOffer(): CredentialExchangeRecord

    async credentials.acceptCredential(): CredentialExchangeRecord

    async credentials.findByRecordId(): CredentialExchangeRecord?

    async credentials.findAllByState(): Array[CredentialExchangeRecord]

    async credentials.findAllByStateAndDidExchangeId(): Array[CredentialExchangeRecord]

    async credentials.getAll(): Array[CredentialExchangeRecord]

    async credentials.findByThreadIdAndDidExchangeId(): CredentialExchangeRecord?

    async credentials.getByThreadIdAndDidExchangeId(): CredentialExchangeRecord

    Proofs

    async proofs.autoAcceptProof(): ProofRecord

    async proofs.acceptProof(): ProofRecord

    async proofs.getCredentialsForProofRequest(): PresentationData

    async proofs.autoSelectCredentialsForProofRequest(): PresentationData

    async proofs.getProofRequestsForConnection(): Array[ProofRecord]

    Routing

    async routing.initialize(): void

    async routing.initiateMessagePickup(): void

    async routing.findDefaultMediator(): MediationRecord?

    async routing.discoverMediation(): MediationRecord?

    async routing.setDefaultMediator(): MediationRecord

    async routing.requestMediation(): MediationRecord

    async routing.getByExchangeId(): MediationRecord

    async routing.findByExchangeId(): MediationRecord

    async routing.getMediators(): Array[MediationRecord]

    async routing.findDefaultMediatorExchange(): DidExchangeRecord?

    async routing.provision(): MediationRecord?

    async routing.getRouting(): Routing

    Basic Messaging

    async basicMessages.send(): BasicMessageRecord

    async basicMessages.findById(): BasicMessageRecord

    async basicMessages.getAll(): Array

    async basicMessages.findByComment(): Array

    async basicMessages.findByDidExchangeId(): Array

    async basicMessages.findByRole(): Array

    Events

    React Native

    Kotlin

    Swift

    Agent API
    DidExchange API
    OutOfBand API
    Credentials API
    Proofs API
    Routing API
    Events API