diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index a0498c755..3f426dae5 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Added + +- Add `legalCountry` as an allowed attribute for set/not-set membership proofs. + ## 8.0.1 ### Breaking changes 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/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'); } 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(); });