From 2a8bd5faf806ccd91a3c06c5773de1f8ced8a7b4 Mon Sep 17 00:00:00 2001 From: gabe Date: Thu, 3 Nov 2022 15:01:18 -0700 Subject: [PATCH 1/5] add new fields --- credential/exchange/model.go | 12 +++++++----- schema/known_schemas/pe-input-descriptor.json | 12 ++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/credential/exchange/model.go b/credential/exchange/model.go index 929a42b2..f83f5433 100644 --- a/credential/exchange/model.go +++ b/credential/exchange/model.go @@ -69,10 +69,10 @@ type PresentationDefinitionEnvelope struct { // PresentationDefinition https://identity.foundation/presentation-exchange/#presentation-definition type PresentationDefinition struct { ID string `json:"id,omitempty" validate:"required"` - InputDescriptors []InputDescriptor `json:"input_descriptors" validate:"required,dive"` Name string `json:"name,omitempty"` Purpose string `json:"purpose,omitempty"` Format *ClaimFormat `json:"format,omitempty" validate:"omitempty,dive"` + InputDescriptors []InputDescriptor `json:"input_descriptors" validate:"required,dive"` SubmissionRequirements []SubmissionRequirement `json:"submission_requirements,omitempty" validate:"omitempty,dive"` // https://identity.foundation/presentation-exchange/#json-ld-framing-feature @@ -269,14 +269,16 @@ type Constraints struct { } type Field struct { - Path []string `json:"path,omitempty" validate:"required"` - ID string `json:"id,omitempty"` - Purpose string `json:"purpose,omitempty"` + ID string `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Path []string `json:"path,omitempty" validate:"required"` + Purpose string `json:"purpose,omitempty"` + Optional bool `json:"optional,omitempty"` + IntentToRetain bool `json:"intent_to_retain,omitempty"` // If a predicate property is present, filter must be too // https://identity.foundation/presentation-exchange/#predicate-feature Predicate *Preference `json:"predicate,omitempty"` Filter *Filter `json:"filter,omitempty"` - Optional bool `json:"optional,omitempty"` } type RelationalConstraint struct { diff --git a/schema/known_schemas/pe-input-descriptor.json b/schema/known_schemas/pe-input-descriptor.json index 92cd6a6c..676f6443 100644 --- a/schema/known_schemas/pe-input-descriptor.json +++ b/schema/known_schemas/pe-input-descriptor.json @@ -31,6 +31,9 @@ "id": { "type": "string" }, + "optional": { + "type": "boolean" + }, "path": { "type": "array", "items": { @@ -40,6 +43,9 @@ "purpose": { "type": "string" }, + "intent_to_retain": { + "type": "boolean" + }, "filter": { "$ref": "http://json-schema.org/draft-07/schema#" } @@ -54,6 +60,9 @@ "id": { "type": "string" }, + "optional": { + "type": "boolean" + }, "path": { "type": "array", "items": { @@ -63,6 +72,9 @@ "purpose": { "type": "string" }, + "intent_to_retain": { + "type": "boolean" + }, "filter": { "$ref": "http://json-schema.org/draft-07/schema#" }, From 30bf60470560cf430c54ebe3cd3c9dd371316e79 Mon Sep 17 00:00:00 2001 From: gabe Date: Thu, 3 Nov 2022 17:04:40 -0700 Subject: [PATCH 2/5] update to presentation exchange v2 --- credential/exchange/model.go | 2 +- credential/exchange/submission.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/credential/exchange/model.go b/credential/exchange/model.go index f83f5433..414adbd0 100644 --- a/credential/exchange/model.go +++ b/credential/exchange/model.go @@ -186,7 +186,7 @@ func (cf *ClaimFormat) FormatValues() []string { // AlgOrProofTypePerFormat for a given format, return the supported alg or proof types. A nil response indicates // that the format is not supported. -func (cf *ClaimFormat) AlgOrProofTypePerFormat(_ string) []string { +func (cf *ClaimFormat) AlgOrProofTypePerFormat() []string { var res []string if cf.JWT != nil { for _, a := range cf.JWT.Alg { diff --git a/credential/exchange/submission.go b/credential/exchange/submission.go index a3b7af0d..624bbd66 100644 --- a/credential/exchange/submission.go +++ b/credential/exchange/submission.go @@ -401,7 +401,7 @@ func filterClaimsByFormat(claims []NormalizedClaim, format *ClaimFormat) []Norma // if the format matches, check the alg type if util.Contains(claim.Format, formatValues) { // get the supported alg or proof types for this format - algOrProofTypes := format.AlgOrProofTypePerFormat(claim.Format) + algOrProofTypes := format.AlgOrProofTypePerFormat() if util.Contains(claim.AlgOrProofType, algOrProofTypes) { filteredClaims = append(filteredClaims, claim) } From 282b4c8a78a257becf1dca9eb5caec68cd7dcc2b Mon Sep 17 00:00:00 2001 From: gabe Date: Thu, 3 Nov 2022 17:14:14 -0700 Subject: [PATCH 3/5] update pe and cm schemas --- credential/manifest/builder.go | 18 +++++++ credential/manifest/builder_test.go | 6 +++ credential/manifest/model.go | 2 + .../known_schemas/cm-credential-manifest.json | 54 +++++++++++++++---- schema/known_schemas/pe-input-descriptor.json | 6 +++ .../pe-presentation-definition-envelope.json | 6 +++ .../pe-presentation-definition.json | 6 +++ .../pe-presentation-submission.json | 2 +- 8 files changed, 88 insertions(+), 12 deletions(-) diff --git a/credential/manifest/builder.go b/credential/manifest/builder.go index 978a72fd..ef3029a8 100644 --- a/credential/manifest/builder.go +++ b/credential/manifest/builder.go @@ -47,6 +47,24 @@ func (cmb *CredentialManifestBuilder) IsEmpty() bool { return reflect.DeepEqual(cmb, &CredentialManifestBuilder{}) } +func (cmb *CredentialManifestBuilder) SetName(name string) error { + if cmb.IsEmpty() { + return errors.New(BuilderEmptyError) + } + + cmb.Name = name + return nil +} + +func (cmb *CredentialManifestBuilder) SetDescription(description string) error { + if cmb.IsEmpty() { + return errors.New(BuilderEmptyError) + } + + cmb.Description = description + return nil +} + func (cmb *CredentialManifestBuilder) SetIssuer(i Issuer) error { if cmb.IsEmpty() { return errors.New(BuilderEmptyError) diff --git a/credential/manifest/builder_test.go b/credential/manifest/builder_test.go index 0b258348..05e87ce1 100644 --- a/credential/manifest/builder_test.go +++ b/credential/manifest/builder_test.go @@ -18,6 +18,12 @@ func TestCredentialManifestBuilder(t *testing.T) { assert.False(t, builder.IsEmpty()) + err = builder.SetName("name") + assert.NoError(t, err) + + err = builder.SetDescription("description") + assert.NoError(t, err) + // set a bad issuer err = builder.SetIssuer(Issuer{ Name: "Satoshi", diff --git a/credential/manifest/model.go b/credential/manifest/model.go index 5d1faf06..65999a4f 100644 --- a/credential/manifest/model.go +++ b/credential/manifest/model.go @@ -19,6 +19,8 @@ const ( type CredentialManifest struct { ID string `json:"id" validate:"required"` SpecVersion string `json:"spec_version" validate:"required"` + Name string `json:"name,omitempty"` + Description string `json:"description,omitempty"` Issuer Issuer `json:"issuer" validate:"required,dive"` OutputDescriptors []OutputDescriptor `json:"output_descriptors" validate:"required,dive"` Format *exchange.ClaimFormat `json:"format,omitempty" validate:"omitempty,dive"` diff --git a/schema/known_schemas/cm-credential-manifest.json b/schema/known_schemas/cm-credential-manifest.json index 9dfb3f4c..b31eda4c 100644 --- a/schema/known_schemas/cm-credential-manifest.json +++ b/schema/known_schemas/cm-credential-manifest.json @@ -3,14 +3,30 @@ "title": "Credential Manifest", "type": "object", "properties": { - "id": { "type": "string" }, - "spec_version": { "type" : "string" }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "spec_version": { + "type": "string" + }, "issuer": { "type": "object", - "required": ["id"], + "required": [ + "id" + ], "properties": { - "id": { "type": "string" }, - "name": { "type": "string" }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, "styles": { "$ref": "https://identity.foundation/wallet-rendering/schemas/entity-styles.json" } @@ -21,12 +37,23 @@ "type": "array", "items": { "type": "object", - "required": ["id", "schema"], + "required": [ + "id", + "schema" + ], "properties": { - "id": { "type": "string" }, - "name": { "type": "string" }, - "description": { "type": "string" }, - "schema": { "type": "string" }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "schema": { + "type": "string" + }, "display": { "type": "object", "properties": { @@ -62,6 +89,11 @@ "$ref": "https://identity.foundation/claim-format-registry/schemas/presentation-definition-claim-format-designations.json" } }, - "required": ["id", "spec_version", "issuer", "output_descriptors"], + "required": [ + "id", + "spec_version", + "issuer", + "output_descriptors" + ], "additionalProperties": false } \ No newline at end of file diff --git a/schema/known_schemas/pe-input-descriptor.json b/schema/known_schemas/pe-input-descriptor.json index 676f6443..f9327eb3 100644 --- a/schema/known_schemas/pe-input-descriptor.json +++ b/schema/known_schemas/pe-input-descriptor.json @@ -46,6 +46,9 @@ "intent_to_retain": { "type": "boolean" }, + "name": { + "type": "string" + }, "filter": { "$ref": "http://json-schema.org/draft-07/schema#" } @@ -78,6 +81,9 @@ "filter": { "$ref": "http://json-schema.org/draft-07/schema#" }, + "name": { + "type": "string" + }, "predicate": { "type": "string", "enum": [ diff --git a/schema/known_schemas/pe-presentation-definition-envelope.json b/schema/known_schemas/pe-presentation-definition-envelope.json index 9d853958..fe05ca56 100644 --- a/schema/known_schemas/pe-presentation-definition-envelope.json +++ b/schema/known_schemas/pe-presentation-definition-envelope.json @@ -43,6 +43,9 @@ "purpose": { "type": "string" }, + "name": { + "type": "string" + }, "intent_to_retain": { "type": "boolean" }, @@ -78,6 +81,9 @@ "filter": { "$ref": "http://json-schema.org/draft-07/schema#" }, + "name": { + "type": "string" + }, "predicate": { "type": "string", "enum": [ diff --git a/schema/known_schemas/pe-presentation-definition.json b/schema/known_schemas/pe-presentation-definition.json index e5dbaf61..7ba8262b 100644 --- a/schema/known_schemas/pe-presentation-definition.json +++ b/schema/known_schemas/pe-presentation-definition.json @@ -43,6 +43,9 @@ "purpose": { "type": "string" }, + "name": { + "type": "string" + }, "intent_to_retain": { "type": "boolean" }, @@ -78,6 +81,9 @@ "filter": { "$ref": "http://json-schema.org/draft-07/schema#" }, + "name": { + "type": "string" + }, "predicate": { "type": "string", "enum": [ diff --git a/schema/known_schemas/pe-presentation-submission.json b/schema/known_schemas/pe-presentation-submission.json index b0f599c1..a9727552 100644 --- a/schema/known_schemas/pe-presentation-submission.json +++ b/schema/known_schemas/pe-presentation-submission.json @@ -28,7 +28,7 @@ "$ref": "#/definitions/descriptor" }, "format": { - "$ref": "https://identity.foundation/claim-format-registry/schemas/presentation-submission-claim-format-designations.json#/definitions/format" + "$ref": "http://identity.foundation/claim-format-registry/schemas/presentation-submission-claim-format-designations.json#/definitions/format" } }, "required": ["id", "path", "format"], From 7c942d8ca0e435d7b16b6764acde2329991bb4a8 Mon Sep 17 00:00:00 2001 From: gabe Date: Fri, 4 Nov 2022 09:11:31 -0700 Subject: [PATCH 4/5] update test --- credential/manifest/builder_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/credential/manifest/builder_test.go b/credential/manifest/builder_test.go index 05e87ce1..03bb9be6 100644 --- a/credential/manifest/builder_test.go +++ b/credential/manifest/builder_test.go @@ -23,7 +23,7 @@ func TestCredentialManifestBuilder(t *testing.T) { err = builder.SetDescription("description") assert.NoError(t, err) - + // set a bad issuer err = builder.SetIssuer(Issuer{ Name: "Satoshi", @@ -114,6 +114,8 @@ func TestCredentialManifestBuilder(t *testing.T) { manifest, err := builder.Build() assert.NoError(t, err) assert.NotEmpty(t, manifest) + assert.Equal(t, "name", manifest.Name) + assert.Equal(t, "description", manifest.Description) } func TestCredentialApplicationBuilder(t *testing.T) { From df9772d2abff340e02c019af5f16125728f692a7 Mon Sep 17 00:00:00 2001 From: gabe Date: Fri, 4 Nov 2022 09:12:05 -0700 Subject: [PATCH 5/5] update codeowners --- CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index ed69c083..1368d0ba 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -6,7 +6,7 @@ # The format is described: https://github.blog/2017-07-06-introducing-code-owners/ # These owners will be the default owners for everything in the repo. -* @decentralgabe @nitro-neal +* @decentralgabe @nitro-neal @andresuribe87 # -----------------------------------------------