The Jolocom SDK will expose a WebSocket channel, via which JSON-RPC request / responses can be exchanged.

At this stage, 3 types of RPC requests are defined, 2 for initiating interactions (i.e. credential issuance and credential requests, and 1 for processing responses sent by the Wallet.). The examples below show how these message types can be used to issue a new credential, and to request a credential from the Wallet.

Examples for a complete flow


Issuing a new credential

The following request is made to the Jolocom SDK (by sending the JSON structure via the websocket connection exposed by the SDK):

{
  "jsonrpc": "2.0", 
  "method": "initiateCredentialOffer", 
  "params": {
    "callbackURL": "<https://condidi.com/interact>", // This endpoint to which the Wallet will send the response
    "offeredCredentials": [{
      "type": "ProofOfEventOrganizerRoleCredential",
    }],
    "claimData": [{
			"type": "ProofOfEventOrganizerRoleCredential",
      "claims": {
        "name": "Joe",
				"surname": "Tester",
        "email": "[email protected]"
      }
	  }]
  },
  "id": 402131 // used to correlate response, randomly generated by the caller
}

The Jolocom SDK will send the following RPC response:

{
  "jsonrpc": "2.0", 
  "result": {
		"interactionId": "aaaccc" // The identifier for the interaction, unique for the entire interaction
    "interactionToken": "eYJ...." // The credential offer assembled and signed by the SDK
  },
  "id": 402131 // same ID as in the request, can be used to match to the request in async use cases
}

At this point, the contents of the interactionToken property can be passed to the Jolocom SmartWallet. This can be done either by encoding the token as a QR code, or by formatting it as a deep link.

Once the wallet receives the request, the user will be prompted to accept the credentials. If they accept, the wallet will send a POST request to the endpoint listed as the callbackURL. The exact contents of the POST body are:

{ "token": "eYJ..."}

The Jolocom SDK can be called with the token as follows:

{ 
  "jsonrpc": "2.0", 
  "method": "processInteractionToken", 
  "params": {
    "interactionToken": "eYJ..." // The token that was posted by the SmartWallet
  },
  "id": 578324 // can be used to match to the request in async use cases
}

At this stage, the SDK will return the following: