Skip to content

Commit

Permalink
Always verify the name
Browse files Browse the repository at this point in the history
  • Loading branch information
lbeder committed Nov 10, 2023
1 parent 3fd054c commit 63c5ef0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion dist/offchain/typed-data-handler.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/offchain/typed-data-handler.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/offchain/typed-data-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export abstract class TypedDataHandler {

let expectedDomain = this.getDomainTypedData();
if (!strict) {
expectedDomain = { ...expectedDomain, name: domain.name, version: domain.version };
expectedDomain = { ...expectedDomain, version: domain.version };
}

if (!isEqual(domain, expectedDomain)) {
Expand Down
7 changes: 3 additions & 4 deletions test/test/eas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -712,13 +712,12 @@ describe('EAS API', () => {
})
).to.throw('Invalid domain');

// Invalid domain verification won't throw, due to the check not being strict, but will fail on signature
await expect(
await expect(() =>
offchain.verifyOffchainAttestationSignature(senderAddress, {
...response,
...{ domain: { ...domain, name: `BAD${domain.name}BAD` } }
})
).to.be.false;
).to.throw('Invalid domain');

// Invalid version verification won't throw, due to the check not being strict, but will fail on signature
await expect(
Expand Down Expand Up @@ -758,7 +757,7 @@ describe('EAS API', () => {

it('should verify offchain attestations with legacy/obsoleted domains', async () => {
const { config } = offchain;
const customOffchain = new CustomOffchain(config, { name: 'XXX', version: '0.0.1' }, new EAS(ZERO_ADDRESS));
const customOffchain = new CustomOffchain(config, '0.0.1', new EAS(ZERO_ADDRESS));

const params = {
version: 1,
Expand Down
9 changes: 2 additions & 7 deletions test/test/helpers/custom-offchain.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import { EAS } from '../../../src/eas';
import { Offchain, OffChainAttestationVersion, TypedDataConfig } from '../../../src/offchain';

interface CustomDomain {
name: string;
version: string;
}

export class CustomOffchain extends Offchain {
constructor(config: TypedDataConfig, domain: CustomDomain, eas: EAS) {
constructor(config: TypedDataConfig, version: string, eas: EAS) {
super(config, OffChainAttestationVersion.Version1, eas);

this.config = { ...this.config, ...domain };
this.config = { ...this.config, version };
}
}

0 comments on commit 63c5ef0

Please sign in to comment.