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

Commit

Permalink
Credential Manifest: add applicant id (#376)
Browse files Browse the repository at this point in the history
* add applicant id

* update version
  • Loading branch information
decentralgabe authored May 9, 2023
1 parent 9374316 commit 6d90443
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 128 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.20.3
go-version: 1.20.4

- name: Install Mage
run: go install github.com/magefile/mage
Expand All @@ -38,7 +38,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.20.3
go-version: 1.20.4

- name: Install Mage
run: go install github.com/magefile/mage
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.20.3
go-version: 1.20.4
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This guide is for you.

| Requirement | Tested Version | Installation Instructions |
|-------------|----------------|--------------------------------------------------------|
| Go | 1.20.3 | [go.dev](https://go.dev/doc/tutorial/compile-install) |
| Go | 1.20.4 | [go.dev](https://go.dev/doc/tutorial/compile-install) |
| Mage | 1.13.0-6 | [magefile.org](https://magefile.org/) |

### Go
Expand All @@ -25,7 +25,7 @@ You may verify your `go` installation via the terminal:

```
$> go version
go version go1.20.3 darwin/amd64
go version go1.20.4 darwin/amd64
```

If you do not have go, we recommend installing it by:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![godoc ssi-sdk](https://img.shields.io/badge/godoc-ssi--sdk-blue)](https://pkg.go.dev/github.com/TBD54566975/ssi-sdk)
[![go version 1.20.3](https://img.shields.io/badge/go_version-1.20.3-brightgreen)](https://golang.org/)
[![go version 1.20.4](https://img.shields.io/badge/go_version-1.20.4-brightgreen)](https://golang.org/)
[![Go Report Card A+](https://goreportcard.com/badge/github.com/TBD54566975/ssi-sdk)](https://goreportcard.com/report/github.com/TBD54566975/ssi-sdk)
[![license Apache 2](https://img.shields.io/badge/license-Apache%202-black)](https://github.com/TBD54566975/ssi-sdk/blob/main/LICENSE)
[![issues](https://img.shields.io/github/issues/TBD54566975/ssi-sdk)](https://github.com/TBD54566975/ssi-sdk/issues)
Expand Down
18 changes: 18 additions & 0 deletions credential/manifest/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,15 @@ func (cab *CredentialApplicationBuilder) IsEmpty() bool {
return reflect.DeepEqual(cab, &CredentialApplicationBuilder{})
}

func (cab *CredentialApplicationBuilder) SetApplicantID(applicantID string) error {
if cab.IsEmpty() {
return errors.New(BuilderEmptyError)
}

cab.Applicant = applicantID
return nil
}

func (cab *CredentialApplicationBuilder) SetApplicationManifestID(manifestID string) error {
if cab.IsEmpty() {
return errors.New(BuilderEmptyError)
Expand Down Expand Up @@ -237,6 +246,15 @@ func (crb *CredentialResponseBuilder) IsEmpty() bool {
return reflect.DeepEqual(crb, &CredentialResponseBuilder{})
}

func (crb *CredentialResponseBuilder) SetApplicantID(applicantID string) error {
if crb.IsEmpty() {
return errors.New(BuilderEmptyError)
}

crb.Applicant = applicantID
return nil
}

func (crb *CredentialResponseBuilder) SetManifestID(manifestID string) error {
if crb.IsEmpty() {
return errors.New(BuilderEmptyError)
Expand Down
6 changes: 6 additions & 0 deletions credential/manifest/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ func TestCredentialApplicationBuilder(t *testing.T) {

assert.False(t, builder.IsEmpty())

err = builder.SetApplicantID("applicant-id")
assert.NoError(t, err)

err = builder.SetApplicationManifestID("manifest-id")
assert.NoError(t, err)

Expand Down Expand Up @@ -178,6 +181,9 @@ func TestCredentialResponseBuilder(t *testing.T) {
err = builder.SetManifestID("manifest-id")
assert.NoError(t, err)

err = builder.SetApplicantID("applicant-id")
assert.NoError(tt, err)

err = builder.SetApplicationID("application-id")
assert.NoError(tt, err)

Expand Down
2 changes: 2 additions & 0 deletions credential/manifest/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ type CredentialApplicationWrapper struct {
type CredentialApplication struct {
ID string `json:"id" validate:"required"`
SpecVersion string `json:"spec_version" validate:"required"`
Applicant string `json:"applicant"`
ManifestID string `json:"manifest_id" validate:"required"`
Format *exchange.ClaimFormat `json:"format" validate:"required,dive"`
// Must be present if the corresponding manifest contains a presentation_definition
Expand Down Expand Up @@ -130,6 +131,7 @@ type CredentialResponseWrapper struct {
type CredentialResponse struct {
ID string `json:"id" validate:"required"`
SpecVersion string `json:"spec_version" validate:"required"`
Applicant string `json:"applicant"`
ManifestID string `json:"manifest_id" validate:"required"`
ApplicationID string `json:"application_id"`
Fulfillment *struct {
Expand Down
1 change: 1 addition & 0 deletions credential/manifest/testdata/cm-application-example-1.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"id": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"spec_version": "https://identity.foundation/credential-manifest/spec/v1.0.0/",
"applicant": "did:example:123",
"manifest_id": "WA-DL-CLASS-A",
"format": {
"ldp_vc": {
Expand Down
1 change: 1 addition & 0 deletions credential/manifest/testdata/cm-response-example-1.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"id": "a30e3b91-fb77-4d22-95fa-871689c322e2",
"spec_version": "https://identity.foundation/credential-manifest/spec/v1.0.0/",
"applicant": "did:example:123",
"manifest_id": "32f54163-7166-48f1-93d8-ff217bdb0653",
"application_id": "b6385066-147c-49d0-9783-261a2154b1fd",
"fulfillment": {
Expand Down
6 changes: 2 additions & 4 deletions credential/manifest/testdata/cm-response-example-2.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
"id": "a30e3b91-fb77-4d22-95fa-871689c322e2",
"spec_version": "https://identity.foundation/credential-manifest/spec/v1.0.0/",
"applicant": "did:example:123",
"manifest_id": "32f54163-7166-48f1-93d8-ff217bdb0653",
"application_id": "b6385066-147c-49d0-9783-261a2154b1fd",
"denial": {
"reason": "Input descriptors 1 and 3 use non-matching schemas.",
"input_descriptors": [
"id-1",
"id-3"
]
"input_descriptors": ["id-1", "id-3"]
}
}
2 changes: 1 addition & 1 deletion did/web/web_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestDIDWebCreateDocFileBytes(t *testing.T) {
})

t.Run("Unhappy Path", func(tt *testing.T) {
_, err := didWebBasic.CreateDocBytes(crypto.KeyType("bad"), nil)
_, err := didWebBasic.CreateDocBytes("bad", nil)
assert.Error(tt, err)
})
}
77 changes: 17 additions & 60 deletions schema/known_schemas/cm-credential-application.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@
"title": "Credential Application",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"spec_version": {
"type": "string"
},
"manifest_id": {
"type": "string"
},
"id": { "type": "string" },
"spec_version": { "type" : "string" },
"manifest_id": { "type": "string" },
"applicant": { "type": "string" },
"format": {
"type": "object",
"patternProperties": {
Expand All @@ -21,14 +16,10 @@
"alg": {
"type": "array",
"minItems": 1,
"items": {
"type": "string"
}
"items": { "type": "string" }
}
},
"required": [
"alg"
],
"required": ["alg"],
"additionalProperties": false
},
"^ldp_vc$|^ldp_vp$|^ldp$": {
Expand All @@ -37,14 +28,10 @@
"proof_type": {
"type": "array",
"minItems": 1,
"items": {
"type": "string"
}
"items": { "type": "string" }
}
},
"required": [
"proof_type"
],
"required": ["proof_type"],
"additionalProperties": false
}
},
Expand All @@ -53,66 +40,36 @@
"presentation_submission": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"definition_id": {
"type": "string"
},
"id": { "type": "string" },
"definition_id": { "type": "string" },
"descriptor_map": {
"type": "array",
"items": {
"$ref": "#/definitions/descriptor"
}
"items": { "$ref": "#/definitions/descriptor" }
}
},
"required": [
"id",
"definition_id",
"descriptor_map"
],
"required": ["id", "definition_id", "descriptor_map"],
"additionalProperties": false
}
},
"definitions": {
"descriptor": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"path": {
"type": "string"
},
"id": { "type": "string" },
"path": { "type": "string" },
"path_nested": {
"type": "object",
"$ref": "#/definitions/descriptor"
},
"format": {
"type": "string",
"enum": [
"jwt",
"jwt_vc",
"jwt_vp",
"ldp",
"ldp_vc",
"ldp_vp"
]
"enum": ["jwt", "jwt_vc", "jwt_vp", "ldp", "ldp_vc", "ldp_vp"]
}
},
"required": [
"id",
"path",
"format"
],
"required": ["id", "path", "format"],
"additionalProperties": false
}
},
"required": [
"id",
"spec_version",
"manifest_id",
"format"
],
"required": ["id", "spec_version", "manifest_id", "format"],
"additionalProperties": false
}
Loading

0 comments on commit 6d90443

Please sign in to comment.