From a4b33c6cbf02902bd6bd26468935f1a6b9d08780 Mon Sep 17 00:00:00 2001 From: Doris Benda Date: Thu, 12 Sep 2024 13:35:24 +0300 Subject: [PATCH 1/3] Add legal country for set and not-set membership proofs --- packages/sdk/CHANGELOG.md | 6 ++++++ packages/sdk/src/id/idProofs.ts | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index a0498c755..7cb0c85af 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixed + +- Add `legalCountry` as allowed attribute for set/not-set memebership proofs. + ## 8.0.1 ### Breaking changes diff --git a/packages/sdk/src/id/idProofs.ts b/packages/sdk/src/id/idProofs.ts index a357a9b2e..6625591d2 100644 --- a/packages/sdk/src/id/idProofs.ts +++ b/packages/sdk/src/id/idProofs.ts @@ -127,6 +127,11 @@ function verifySetStatement(statement: MembershipStatement | NonMembershipStatem throw new Error('idDocType values must be one from IdDocType enum'); } break; + case AttributeKeyString.legalCountry: + if (!statement.set.every(isISO3166_1Alpha2)) { + throw new Error(statement.attributeTag + ' values must be ISO3166-1 Alpha 2 codes in upper case'); + } + break; default: throw new Error(statement.attributeTag + ' is not allowed to be used in ' + typeName + ' statements'); } From 32ba954a894b5e1ce94b4619ed10ad0c9f458031 Mon Sep 17 00:00:00 2001 From: Doris Benda Date: Thu, 12 Sep 2024 13:53:53 +0300 Subject: [PATCH 2/3] Fix id proof tests --- packages/sdk/src/id/idProofTypes.ts | 8 +++++++- packages/sdk/test/ci/idProofs.test.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/sdk/src/id/idProofTypes.ts b/packages/sdk/src/id/idProofTypes.ts index 15797216d..3ce0fb7a8 100644 --- a/packages/sdk/src/id/idProofTypes.ts +++ b/packages/sdk/src/id/idProofTypes.ts @@ -45,4 +45,10 @@ export const attributesWithRange: AttributeKey[] = ['dob', 'idDocIssuedAt', 'idD /** * The attributes that can be used for (non)membership statements */ -export const attributesWithSet: AttributeKey[] = ['countryOfResidence', 'nationality', 'idDocType', 'idDocIssuer']; +export const attributesWithSet: AttributeKey[] = [ + 'countryOfResidence', + 'nationality', + 'idDocType', + 'idDocIssuer', + 'legalCountry', +]; diff --git a/packages/sdk/test/ci/idProofs.test.ts b/packages/sdk/test/ci/idProofs.test.ts index e86fa3f43..165e56c85 100644 --- a/packages/sdk/test/ci/idProofs.test.ts +++ b/packages/sdk/test/ci/idProofs.test.ts @@ -74,7 +74,7 @@ test('Upper bound must be greater than lower bound for attribute statement', () test('Unknown attribute tags are rejected', () => { const builder = new IdStatementBuilder(true); expect(() => builder.addMembership(-1 as unknown as AttributesKeys, ['DK'])).toThrow(); - expect(() => builder.addMembership(15 as unknown as AttributesKeys, ['DK'])).toThrow(); + expect(() => builder.addMembership(16 as unknown as AttributesKeys, ['DK'])).toThrow(); expect(() => builder.addMembership(1000 as unknown as AttributesKeys, ['DK'])).toThrow(); }); From 6c9e337b33814c4c004e089af8d9fcec4fab1b5d Mon Sep 17 00:00:00 2001 From: Doris Benda Date: Thu, 12 Sep 2024 14:26:46 +0300 Subject: [PATCH 3/3] Fix typo --- packages/sdk/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index 7cb0c85af..3f426dae5 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -2,9 +2,9 @@ ## Unreleased -### Fixed +### Added -- Add `legalCountry` as allowed attribute for set/not-set memebership proofs. +- Add `legalCountry` as an allowed attribute for set/not-set membership proofs. ## 8.0.1