Skip to content

Commit 9d1358d

Browse files
committed
Support validating proof with domain expressed as an array.
1 parent 8b7beb0 commit 9d1358d

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# jsonld-signatures ChangeLog
22

3+
## 11.4.0 - 2024-12-dd
4+
5+
### Added
6+
- Add support for validating proof with `domain` expressed as an array.
7+
38
## 11.3.2 - 2024-11-06
49

510
### Fixed

lib/purposes/AuthenticationProofPurpose.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,23 @@ module.exports = class AuthenticationProofPurpose extends
2525
try {
2626
// check challenge
2727
if(proof.challenge !== this.challenge) {
28-
throw new Error('The challenge is not as expected; ' +
28+
throw new Error(
29+
'The challenge is not as expected; ' +
2930
`challenge="${proof.challenge}", expected="${this.challenge}"`);
3031
}
3132

3233
// check domain
33-
if(this.domain !== undefined && proof.domain !== this.domain) {
34-
throw new Error('The domain is not as expected; ' +
35-
`domain="${proof.domain}", expected="${this.domain}"`);
34+
if(this.domain !== undefined) {
35+
// `proof.domain` must equal `this.domain` OR if `proof.domain` is
36+
// an array, the array must include `this.domain` as an element
37+
const {domain} = proof;
38+
if(!(domain === this.domain ||
39+
(Array.isArray(domain) && domain.includes(this.domain)))) {
40+
throw new Error(
41+
'The domain is not as expected; ' +
42+
`domain=${JSON.stringify(domain)}, ` +
43+
`expected=${JSON.stringify(this.domain)}`);
44+
}
3645
}
3746

3847
return super.validate(

0 commit comments

Comments
 (0)