Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Connectionless presentation #272

Merged
merged 5 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 7 additions & 68 deletions demos/next/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion demos/next/src/components/OOB.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ export const OOB: React.FC<{ agent: SDK.Agent, pluto: SDK.Domain.Pluto; }> = pro

return <>
<h1 className="mb-4 text-lg font-extrabold tracking-tight leading-none text-gray-900 dark:text-white">
Establish DIDCOMM Connections
Accept OOB (Connections / Presentatios)
</h1>
<p className="mb-4 text-md text-gray-900 dark:text-white">This screen can help you establish a connection with anothe entity, wallet or agent. But also it allows accepting an out of band verification request, when a verifier is asking u to prove him something without a pre-existing connection, what we call "Connectionless presentation".</p>
<AgentRequire text="Agent required You cannot process an OOB invitation while the agent is not running.">
<p>
<input
Expand Down
56 changes: 56 additions & 0 deletions docs/examples/ConnectionlessPresentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Cross-Platform Edge SDK Verification
## Requirements
1. A working Identus Mediator and an Identus Cloud Agent.
2. A holder who already has a JWT Credential issued by a known issuer (prism:did) [Holder A]


> NOTE:
>
> Please follow the [Quick started guide](../../docs/quick-start) to complete steps 1, 2, 3


## Flow
1. The verifier will need to generate an invitation url as follows:

```
curl --location 'http:///cloud-agent/present-proof/presentations/invitation' \
--header 'Content-Type: application/json' \
--data '{
"goalCode" : "present-vp",
"goal" : "Request proof of vaccination information",
"proofs": [],
"options": {
"challenge": "11c91493-01b3-4c4d-ac36-b336bab5bddf",
"domain": "https://prism-verifier.com"
}
}
```

The response will look as follows:

```
{
"presentationId": "715bc063-cd61-4049-834c-465b3eb19042",
"thid": "71a16da3-97ff-460a-b5f9-25a61fe864f4",
"role": "Verifier",
"status": "InvitationGenerated",
"proofs": [],
"data": [],
"goalCode": "present-vp",
"goal": "Request proof of vaccination information",
"myDid": "did:peer:2.Ez6LSt2C1xviB7nFEUHJAyWqvDF2xyJtQHWafQMxmy1SySoH6.Vz6MkgMChqZVQ47G88EBY6QZoPbBsCqByhtyfA3TQpyBKn7Ej.SeyJ0IjoiZG0iLCJzIjp7InVyaSI6Imh0dHA6Ly8xOTIuMTY4LjEuNDQ6ODAwMC9kaWRjb21tIiwiciI6W10sImEiOlsiZGlkY29tbS92MiJdfX0",
"invitation": {
"id": "71a16da3-97ff-460a-b5f9-25a61fe864f4",
"type": "https://didcomm.org/out-of-band/2.0/invitation",
"from": "did:peer:2.Ez6LSt2C1xviB7nFEUHJAyWqvDF2xyJtQHWafQMxmy1SySoH6.Vz6MkgMChqZVQ47G88EBY6QZoPbBsCqByhtyfA3TQpyBKn7Ej.SeyJ0IjoiZG0iLCJzIjp7InVyaSI6Imh0dHA6Ly8xOTIuMTY4LjEuNDQ6ODAwMC9kaWRjb21tIiwiciI6W10sImEiOlsiZGlkY29tbS92MiJdfX0",
"invitationUrl": "https://my.domain.com/path?_oob=eyJpZCI6IjcxYTE2ZGEzLTk3ZmYtNDYwYS1iNWY5LTI1YTYxZmU4NjRmNCIsInR5cGUiOiJodHRwczovL2RpZGNvbW0ub3JnL291dC1vZi1iYW5kLzIuMC9pbnZpdGF0aW9uIiwiZnJvbSI6ImRpZDpwZWVyOjIuRXo2TFN0MkMxeHZpQjduRkVVSEpBeVdxdkRGMnh5SnRRSFdhZlFNeG15MVN5U29INi5WejZNa2dNQ2hxWlZRNDdHODhFQlk2UVpvUGJCc0NxQnlodHlmQTNUUXB5QktuN0VqLlNleUowSWpvaVpHMGlMQ0p6SWpwN0luVnlhU0k2SW1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LCJmb3JtYXQiOiJwcmlzbS9qd3QifV0sInRoaWQiOiI3MWExNmRhMy05N2ZmLTQ2MGEtYjVmOS0yNWE2MWZlODY0ZjQiLCJmcm9tIjoiZGlkOnBlZXI6Mi5FejZMU3QyQzF4dmlCN25GRVVISkF5V3F2REYyeHlKdFFIV2FmUU14bXkxU3lTb0g2LlZ6Nk1rZ01DaHFaVlE0N0c4OEVCWTZRWm9QYkJzQ3FCeWh0eWZBM1RRcHlCS243RWouU2V5SjBJam9pWkcwaUxDSnpJanA3SW5WeWFTSTZJbWgwZEhBNkx5OHhPVEl1TVRZNExqRXVORFE2T0RBd01DOWthV1JqYjIxdElpd2ljaUk2VzEwc0ltRWlPbHNpWkdsa1kyOXRiUzkyTWlKZGZYMCJ9fX1dLCJjcmVhdGVkX3RpbWUiOjE3MjQ0MjY1NjgsImV4cGlyZXNfdGltZSI6MTcyNDQyNjg2OH0="
},
"metaRetries": 5
}
```

The Verifier will make this available to the holder in shape of QA code, link, etc.

2. The holder then opens its the Edge Agent Wallet SDK, "Connections tab" and will pase the invitation link in the field.

Once the invitation is parsed, the user will then be able to see a new Verification request, choose one of the available credentials and send the proof as the verifier requested.
11 changes: 9 additions & 2 deletions docs/examples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ Here, we have the basic implementations and tutorials for the Identus Edge Agent

## Tutorials

### Cross platform DK Verification
### Cross platform SDK Verification

Start a verification flow from an Edge Agent (holder wallet) and another holder to request (a did) to send you a credential proof for a specific issuer and specific claims.

[Start tutorial](./SDKVerification.md)
[Start tutorial](./SDKVerification.md)


### Connection less presentation

Trigger the verifier to generate an out of band verification request. It will work exactly as the didcomm connection invitation links

[Start tutorial](./ConnectionlessPresentation.md)
25 changes: 15 additions & 10 deletions externals/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ buildDIDComm() {
#The code will fully work
cd "${GenDIDComm}-wasm-browser"
if is_mac; then
sed -i '' "/if (typeof input === 'undefined') {/,/}/d" didcomm_js.js
sed -i '' "/if (typeof module_or_path === 'undefined') {/,/}/d" didcomm_js.js
sed -i '' "/if (typeof input === 'undefined') {/,/}/d" didcomm_js.js;
sed -i '' "/if (typeof module_or_path === 'undefined') {/,/}/d" didcomm_js.js;
else
sed -i "/if (typeof input === 'undefined') {/,/}/d" didcomm_js.js
sed -i "/if (typeof module_or_path === 'undefined') {/,/}/d" didcomm_js.js
sed -i "/if (typeof input === 'undefined') {/,/}/d" didcomm_js.js;
sed -i "/if (typeof module_or_path === 'undefined') {/,/}/d" didcomm_js.js;
fi

cd $ExternalsDir
Expand All @@ -71,10 +71,13 @@ buildJWT() {
#This code fails on browser when wasm is first loaded, it can just be ignored
#The code will fully work
cd "${GenJWERust}-wasm-browser"

if is_mac; then
sed -i '' "/if (typeof \(input\|module_or_path\) === 'undefined') {/,/}/d" jwe_rust.js
sed -i '' "/if (typeof input === 'undefined') {/,/}/d" jwe_rust.js;
sed -i '' "/if (typeof module_or_path === 'undefined') {/,/}/d" jwe_rust.js;
else
sed -i "/if (typeof \(input\|module_or_path\) === 'undefined') {/,/}/d" jwe_rust.js
sed -i "/if (typeof input === 'undefined') {/,/}/d" jwe_rust.js;
sed -i "/if (typeof module_or_path === 'undefined') {/,/}/d" jwe_rust.js;
fi

cd $ExternalsDir
Expand All @@ -96,13 +99,15 @@ buildAnonCreds() {
#This code fails on browser when wasm is first loaded, it can just be ignored
#The code will fully work
cd "${GenAnonCreds}-wasm-browser"
if is_mac; then
sed -i '' "/if (typeof \(input\|module_or_path\) === 'undefined') {/,/}/d" "./${AnonCreds}_wasm.js"

if is_mac; then
sed -i '' "/if (typeof input === 'undefined') {/,/}/d" "./${AnonCreds}_wasm.js";
sed -i '' "/if (typeof module_or_path === 'undefined') {/,/}/d" "./${AnonCreds}_wasm.js";
else
sed -i "/if (typeof \(input\|module_or_path\) === 'undefined') {/,/}/d" "./${AnonCreds}_wasm.js"

sed -i "/if (typeof input === 'undefined') {/,/}/d" "./${AnonCreds}_wasm.js";
sed -i "/if (typeof module_or_path === 'undefined') {/,/}/d" "./${AnonCreds}_wasm.js";
fi

cd $ExternalsDir
git submodule | grep $AnonCreds | awk '{print $1}' > "./${AnonCreds}.commit"
}
Expand Down
19 changes: 13 additions & 6 deletions src/domain/models/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ export class Message implements Pluto.Storable {

const body = asJsonObj(messageObj.body);

if (isNil(messageObj.piuri) || !isString(messageObj.piuri)) {
if (
(isNil(messageObj.piuri) || !isString(messageObj.piuri)) &&
(isNil(messageObj.type) || !isString(messageObj.type))) {
throw new AgentError.InvalidMessageError("undefined or wrong piuri");
}

Expand All @@ -86,7 +88,7 @@ export class Message implements Pluto.Storable {

if (
(notNil(messageObj.ack) && !isArray(messageObj.ack)) ||
messageObj.ack.some((x: any) => !isString(x))
messageObj.ack && messageObj.ack.some((x: any) => !isString(x))
) {
throw new AgentError.InvalidMessageError("undefined or wrong ack");
}
Expand Down Expand Up @@ -123,7 +125,7 @@ export class Message implements Pluto.Storable {
});

const id = messageObj.id || undefined;
const piuri = messageObj.piuri;
const piuri = messageObj.piuri || messageObj.type;
const thid = messageObj.thid;
const extraHeaders = asJsonObj(messageObj.extra_headers ?? messageObj.extraHeaders);
const createdVal = (messageObj.created_time ?? messageObj.createdTime);
Expand Down Expand Up @@ -166,7 +168,7 @@ export class Message implements Pluto.Storable {
}

static isJsonAttachment(data: any): data is AttachmentJsonData {
return data.data !== undefined;
return data.data !== undefined || data.json !== undefined;
}
}

Expand Down Expand Up @@ -196,7 +198,12 @@ export namespace Message {
}

if (isJson(attachment.data)) {
const decoded = attachment.data.data;
let decoded: any;
if ("data" in attachment.data) {
decoded = attachment.data.data;
} else if ("json" in attachment.data) {
decoded = attachment.data.json;
}
return typeof decoded === "object"
? decoded
: JSON.parse(decoded);
Expand All @@ -212,7 +219,7 @@ export namespace Message {

const isJson = (data: AttachmentData): data is AttachmentJsonData => {
// ?? why do we mutate json -> data in didcomm Wrapper
return "data" in data;
return "data" in data || "json" in data;
};
}
}
Loading
Loading