Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Adding credential application CRUD and validation #94

Merged
merged 10 commits into from
Sep 19, 2022

Conversation

nitro-neal
Copy link
Contributor

This is the implementation of the Credential Application CRUD and Apply functionality according to SIP 2
https://github.com/TBD54566975/ssi-service/tree/main/sip/sips/sip_2

PUT Manifest Input (We need a valid manifest ID to do an application)


{
  "@context": "",
  "issuer" : "did:example:123",
  "outputDescriptors": [
            {
                "id": "odid1",
                "schema": "https://test.com/schema",
                "name": "good ID",
                "description": "it's all good"
            },
            {
                "id": "odid2",
                "schema": "https://test.com/schema",
                "name": "good ID",
                "description": "it's all good"
            }
        ],
   "presentationDefinition": {
    "id": "test",
    "input_descriptors": [
      {
        "id": "id1",
        "constraints" : 
            {
                "fields" : [ 
                    {
                    "path" : [
                        "path1"
                    ]
                    }
                ]
            }
        

      }
    ]
  }
}

PUT Application Input


{
  "manifestId" : "manifest-id-on-put-manifest-response",
  "presentationSubmission": {
    "id": "id1",
    "definition_id" :"defid",
    "descriptor_map": [
        {
        "id": "id1",
        "format": "jwt",
        "path": "pth"
        }
    ]
    }
}

Application Output


{
    "application": {
        "credential_application": {
            "id": "b4ced4a4-3568-4885-874b-b95efebc7e80",
            "manifest_id": "14fdc7c5-0b37-47b5-a711-7da1215cd118",
            "format": {
                "jwt": {
                    "alg": [
                        "EdDSA"
                    ]
                }
            }
        },
        "presentation_submission": {
            "id": "id1",
            "definition_id": "defid",
            "descriptor_map": [
                {
                    "id": "id1",
                    "format": "jwt",
                    "path": "pth"
                }
            ]
        }
    }
}

image

@codecov-commenter
Copy link

codecov-commenter commented Sep 13, 2022

Codecov Report

Attention: Patch coverage is 13.17829% with 112 lines in your changes missing coverage. Please review.

Project coverage is 23.90%. Comparing base (9fa45a8) to head (6be3233).
Report is 381 commits behind head on main.

Files with missing lines Patch % Lines
pkg/server/router/manifest.go 0.88% 112 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #94      +/-   ##
==========================================
- Coverage   25.94%   23.90%   -2.04%     
==========================================
  Files          14       14              
  Lines         844      962     +118     
==========================================
+ Hits          219      230      +11     
- Misses        594      701     +107     
  Partials       31       31              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@decentralgabe decentralgabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, minor comments. main question is whether the API should be to create an application from a presentation submission/manifest id like you have or should we accept an already formed application.

I had conceived of it working opposite to how you have it but open to this

pkg/server/router/manifest.go Outdated Show resolved Hide resolved
pkg/service/manifest/manifest.go Outdated Show resolved Hide resolved
pkg/service/manifest/manifest.go Outdated Show resolved Hide resolved
pkg/service/manifest/manifest.go Outdated Show resolved Hide resolved
pkg/service/manifest/manifest.go Outdated Show resolved Hide resolved
pkg/service/manifest/manifest.go Outdated Show resolved Hide resolved
pkg/service/manifest/manifest.go Outdated Show resolved Hide resolved
pkg/service/manifest/storage/bolt.go Show resolved Hide resolved
pkg/service/manifest/manifest.go Outdated Show resolved Hide resolved
pkg/service/manifest/storage/storage.go Outdated Show resolved Hide resolved
@nitro-neal
Copy link
Contributor Author

Updated Input:

Create Manifest Input:

{
  "@context": "",
  "issuer" : "did:example:123",
  "outputDescriptors": [
            {
                "id": "odid1",
                "schema": "https://test.com/schema",
                "name": "good ID",
                "description": "it's all good"
            },
            {
                "id": "odid2",
                "schema": "https://test.com/schema",
                "name": "good ID",
                "description": "it's all good"
            }
        ],
   "presentationDefinition": {
    "id": "test",
    "input_descriptors": [
      {
        "id": "id1",
        "constraints" : 
            {
                "fields" : [ 
                    {
                    "path" : [
                        "path1"
                    ]
                    }
                ]
            }
        

      }
    ]
  }
}

Create Manifest Output:

{
    "manifest": {
        "id": "2552f418-39c8-4fb1-83c6-d9dc17b81980",
        "spec_version": "https://identity.foundation/credential-manifest/spec/v1.0.0/",
        "issuer": {
            "id": "did:example:123",
            "name": "did:example:123"
        },
        "output_descriptors": [
            {
                "id": "odid1",
                "schema": "https://test.com/schema",
                "name": "good ID",
                "description": "it's all good"
            },
            {
                "id": "odid2",
                "schema": "https://test.com/schema",
                "name": "good ID",
                "description": "it's all good"
            }
        ],
        "format": {
            "jwt": {
                "alg": [
                    "EdDSA"
                ]
            }
        },
        "presentation_definition": {
            "id": "test",
            "input_descriptors": [
                {
                    "id": "id1",
                    "constraints": {
                        "fields": [
                            {
                                "path": [
                                    "path1"
                                ]
                            }
                        ]
                    }
                }
            ]
        }
    }
}

Submit Application Input:

{
  "manifestId" : "2552f418-39c8-4fb1-83c6-d9dc17b81980",
  "presentationSubmission": {
    "id": "id1",
    "definition_id" :"defid",
    "descriptor_map": [
        {
        "id": "id1",
        "format": "jwt",
        "path": "pth"
        }
    ]
    }
}

Submit Application Output:

{
    "response": {
        "id": "7e6e314c-4545-4243-ab1c-ba28aacc6aa9",
        "spec_version": "https://identity.foundation/credential-manifest/spec/v1.0.0/",
        "manifest_id": "2552f418-39c8-4fb1-83c6-d9dc17b81980",
        "application_id": "0105f88f-12cf-446b-aecf-4deb6d537ed4",
        "fulfillment": {
            "descriptor_map": [
                {
                    "id": "id1",
                    "format": "jwt",
                    "path": "pth"
                }
            ]
        }
    },
    "credentials": [
        {
            "@context": [
                "https://www.w3.org/2018/credentials/v1"
            ],
            "id": "8b85cd47-c5a5-403c-a892-759d730bb761",
            "type": [
                "VerifiableCredential"
            ],
            "issuer": "did:example:123",
            "issuanceDate": "2022-09-16T18:50:27Z",
            "credentialSubject": {
                "id": "0105f88f-12cf-446b-aecf-4deb6d537ed4"
            }
        },
        {
            "@context": [
                "https://www.w3.org/2018/credentials/v1"
            ],
            "id": "e668b563-b848-400a-8e1d-cb47e064a5a0",
            "type": [
                "VerifiableCredential"
            ],
            "issuer": "did:example:123",
            "issuanceDate": "2022-09-16T18:50:27Z",
            "credentialSubject": {
                "id": "0105f88f-12cf-446b-aecf-4deb6d537ed4"
            }
        }
    ]
}

@nitro-neal
Copy link
Contributor Author

Ok much better now with objects at top level of request:

Create Manifest Input:

{
    "manifest":
        {
        "id": "WA-DL-CLASS-A",
        "spec_version": "https://identity.foundation/credential-manifest/spec/v1.0.0/",
        "issuer": {
            "id": "did:example:123?linked-domains=3"
        },
        "output_descriptors": [
            {
            "id": "driver_license_output",
            "schema": "https://schema.org/EducationalOccupationalCredential"
            }
        ],
        "presentation_definition": {
            "id": "test",
            "input_descriptors": [
                {
                "id": "id1",
                "constraints" : 
                    {
                        "fields" : [ 
                            {
                            "path" : [
                                "path1"
                            ]
                            }
                        ]
                    }
                }
            ]
        }
    }
}

Create Manifest Output:

{
    "manifest": {
        "id": "WA-DL-CLASS-A",
        "spec_version": "https://identity.foundation/credential-manifest/spec/v1.0.0/",
        "issuer": {
            "id": "did:example:123?linked-domains=3"
        },
        "output_descriptors": [
            {
                "id": "driver_license_output",
                "schema": "https://schema.org/EducationalOccupationalCredential"
            }
        ],
        "presentation_definition": {
            "id": "test",
            "input_descriptors": [
                {
                    "id": "id1",
                    "constraints": {
                        "fields": [
                            {
                                "path": [
                                    "path1"
                                ]
                            }
                        ]
                    }
                }
            ]
        }
    }
}

Submit Application Input:

{
    "requesterDid" : "did:user:123",
    "application": {
        "id": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
        "spec_version": "https://identity.foundation/credential-manifest/spec/v1.0.0/",
        "manifest_id": "WA-DL-CLASS-A",
        "format": {
            "ldp_vc": {
                "proof_type": [
                    "JsonWebSignature2020",
                    "EcdsaSecp256k1Signature2019"
                ]
            }
        },
        "presentation_submission": {
            "id": "a30e3b91-fb77-4d22-95fa-871689c322e2",
            "definition_id": "32f54163-7166-48f1-93d8-ff217bdb0653",
            "descriptor_map": [
                {
                    "id": "id1",
                    "format": "jwt_vc",
                    "path": "$.verifiableCredential[0]"
                }
            ]
        }
    }
}

Submit Application Output:

{
    "response": {
        "id": "b7dc34e4-b8b3-4331-8fb7-b5d5bfb17799",
        "spec_version": "https://identity.foundation/credential-manifest/spec/v1.0.0/",
        "manifest_id": "WA-DL-CLASS-A",
        "application_id": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
        "fulfillment": {
            "descriptor_map": [
                {
                    "id": "id1",
                    "format": "jwt_vc",
                    "path": "$.verifiableCredential[0]"
                }
            ]
        }
    },
    "credentials": [
        {
            "@context": [
                "https://www.w3.org/2018/credentials/v1"
            ],
            "id": "43738ead-6172-4fc2-849b-7e04d502c41e",
            "type": [
                "VerifiableCredential"
            ],
            "issuer": "did:example:123?linked-domains=3",
            "issuanceDate": "2022-09-16T23:45:52Z",
            "credentialSubject": {
                "id": "did:user:123"
            }
        }
    ]
}

Copy link
Member

@decentralgabe decentralgabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@decentralgabe decentralgabe merged commit dd17043 into main Sep 19, 2022
@decentralgabe decentralgabe deleted the sip-2-create-credential-application-crud-ose-27 branch September 19, 2022 01:17
decentralgabe pushed a commit that referenced this pull request Sep 20, 2022
…se-103

* origin/main:
  upgrade to go 1.19 (#104)
  Bump go.opentelemetry.io/otel/exporters/jaeger from 1.9.0 to 1.10.0 (#98)
  Bump go.opentelemetry.io/otel/sdk from 1.9.0 to 1.10.0 (#99)
  Bump go.opentelemetry.io/otel from 1.9.0 to 1.10.0 (#97)
  Bump github.com/magefile/mage from 1.13.0 to 1.14.0 (#100)
  Bump go.opentelemetry.io/otel/trace from 1.9.0 to 1.10.0 (#101)
  Adding credential application CRUD and validation (#94)
  SiP-3 to accepted with some small changes

# Conflicts:
#	go.mod
#	go.sum
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants