Aries RFCs provides Out-of-Band protocol describing the way of creating new connections and reusing of existing.
Futheremore Out-of-Band allows to attach an additional action which should be started right after connection completion.
This document contains guidelines on how to handle all possible cases for Out-of-Band invitation using Mobile-SDK.
On scanned Out-of-Band Invitation application should check whether connection already exists or not.
Connection exists if one of the following conditions resolve for one of the existing connections:
-
@id
field of original invitation is the same - means that we scan exactly the same invitation JSON.
-
public_did
field of original invitation is the same - means that we scan invitation from same Inviter
-
recipient_keys[0]
field of original invitation is the same - means that we scan invitation from same Inviter
The next steps depend on connection existence and the Invitation format. Specifically on values of handshake_protocols
and request~attach
fields.
`handshake_protocols` Present? |
`request~attach` Present? |
Connection exists? |
Actions |
NO |
NO |
NO |
- Invalid Invitation format. Throw error.
|
NO |
NO |
YES |
- Invalid Invitation format. Throw error.
|
YES |
NO |
NO |
- Call ConnectionApi.vcxCreateConnectionWithOutofbandInvite function to accept Invitation and create Connection state object.
- Complete Connection with regular steps.
- ConnectionApi.vcxConnectionConnect to start connection
- Wait until complete: int state = ConnectionApi.vcxConnectionUpdateState in a loop until state != 4
|
NO |
YES |
NO |
-
Call ConnectionApi.vcxCreateConnectionWithOutofbandInvite function to accept Invitation and create Connection state object.
-
Connection will be immediately created in the completed state - 4.
-
Extract the original message from invitation request~attach field:
[appDelegate.sdkApi extractAttachedMessage:invite
completion:^(NSError *error, NSString *attachedMessage) {
// ...
}];
String attachment = UtilsApi.vcxExtractAttachedMessage(invite).get();
-
Start protocol related to the extracted message:
- proof request - DisclosedProofApi.proofCreateWithRequest
- question - answer question
-
Complete protocol using connection created on step 1.
|
YES |
YES |
NO |
-
Call ConnectionApi.vcxCreateConnectionWithOutofbandInvite function to accept Invitation and create Connection state object.
-
Complete Connection with regular steps.
- ConnectionApi.vcxConnectionConnect to start connection
- Wait until complete: int state = ConnectionApi.vcxConnectionUpdateState in a loop until state != 4
-
Extract the original message from invitation request~attach field:
[appDelegate.sdkApi extractAttachedMessage:invite
completion:^(NSError *error, NSString *attachedMessage) {
// ...
}];
String attachment = UtilsApi.vcxExtractAttachedMessage(invite).get();
-
Start protocol related to the extracted message:
- credential offer - CredentialApi.credentialCreateWithOffer ...
- proof request - DisclosedProofApi.proofCreateWithRequest ...
- question - answer question ...
-
Complete protocol using connection created on step 1.
|
YES |
NO |
YES |
- Reuse existing connection.
- call ConnectionApi.connectionSendReuse using existing connection.
- wait until
handshake-reuse-accepted message is received.
- UtilsApi.vcxGetMessages to download message
- find message by thread['@thid']
|
NO |
YES |
YES |
-
Extract the original message from invitation request~attach field:
[appDelegate.sdkApi extractAttachedMessage:invite
completion:^(NSError *error, NSString *attachedMessage) {
// ...
}];
String attachment = UtilsApi.vcxExtractAttachedMessage(invite).get();
-
Start protocol related to the extracted message:
- credential offer - CredentialApi.credentialCreateWithOffer ...
- proof request - DisclosedProofApi.proofCreateWithRequest
- question - answer question
-
Complete protocol using existing connection.
|
YES |
YES |
YES |
-
Reuse existing connection.
- call ConnectionApi.connectionSendReuse using existing connection.
- wait until
handshake-reuse-accepted message is received.
- UtilsApi.vcxGetMessages to download message
- find message by thread['@thid']
-
Extract the original message from invitation request~attach field:
[appDelegate.sdkApi extractAttachedMessage:invite
completion:^(NSError *error, NSString *attachedMessage) {
// ...
}];
String attachment = UtilsApi.vcxExtractAttachedMessage(invite).get();
-
Start protocol related to the extracted message:
- credential offer - CredentialApi.credentialCreateWithOffer ...
- proof request - DisclosedProofApi.proofCreateWithRequest
- question - answer question
-
Complete protocol using existing connection.
|