diff --git a/dist/offchain/typed-data-handler.js b/dist/offchain/typed-data-handler.js index b0b3538..c71d4c0 100644 --- a/dist/offchain/typed-data-handler.js +++ b/dist/offchain/typed-data-handler.js @@ -38,7 +38,7 @@ class TypedDataHandler { const domain = { ...response.domain, chainId: BigInt(response.domain.chainId) }; let expectedDomain = this.getDomainTypedData(); if (!strict) { - expectedDomain = { ...expectedDomain, name: domain.name, version: domain.version }; + expectedDomain = { ...expectedDomain, version: domain.version }; } if (!(0, isEqual_1.default)(domain, expectedDomain)) { throw new Error('Invalid domain'); diff --git a/dist/offchain/typed-data-handler.js.map b/dist/offchain/typed-data-handler.js.map index 38e20ea..4de5cae 100644 --- a/dist/offchain/typed-data-handler.js.map +++ b/dist/offchain/typed-data-handler.js.map @@ -1 +1 @@ -{"version":3,"file":"typed-data-handler.js","sourceRoot":"","sources":["../../src/offchain/typed-data-handler.ts"],"names":[],"mappings":";;;;AAAA,mCASgB;AAChB,qEAAqC;AACrC,oCAAwC;AA6E3B,QAAA,aAAa,GAAG,oFAAoF,CAAC;AAElH,MAAsB,gBAAgB;IAC7B,MAAM,CAAkB;IAE/B,YAAY,MAAuB;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEM,kBAAkB;QACvB,OAAO,IAAA,kBAAS,EACd,iBAAQ,CAAC,eAAe,EAAE,CAAC,MAAM,CAC/B,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,EACvD;YACE,IAAA,kBAAS,EAAC,IAAA,oBAAW,EAAC,qBAAa,CAAC,CAAC;YACrC,IAAA,kBAAS,EAAC,IAAA,oBAAW,EAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACxC,IAAA,kBAAS,EAAC,IAAA,oBAAW,EAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC3C,IAAI,CAAC,MAAM,CAAC,OAAO;YACnB,IAAI,CAAC,MAAM,CAAC,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AAE;YACpC,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;SACnC;QAED,IAAI,QAAQ,CAAC,WAAW,KAAK,KAAK,CAAC,WAAW,EAAE;YAC9C,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;SACzC;QAED,IAAI,CAAC,IAAA,iBAAO,EAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE;YACzC,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;SAClC;QAED,IAAI,QAAQ,KAAK,oBAAY,EAAE;YAC7B,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;SACpC;QAED,MAAM,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC;QAC/B,MAAM,GAAG,GAAG,kBAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,IAAA,gBAAO,EAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,IAAA,gBAAO,EAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC;QACtG,MAAM,gBAAgB,GAAG,IAAA,wBAAe,EAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAExF,OAAO,IAAA,mBAAU,EAAC,QAAQ,CAAC,KAAK,IAAA,mBAAU,EAAC,gBAAgB,CAAC,CAAC;IAC/D,CAAC;CACF;AA9ED,4CA8EC"} \ No newline at end of file +{"version":3,"file":"typed-data-handler.js","sourceRoot":"","sources":["../../src/offchain/typed-data-handler.ts"],"names":[],"mappings":";;;;AAAA,mCASgB;AAChB,qEAAqC;AACrC,oCAAwC;AA6E3B,QAAA,aAAa,GAAG,oFAAoF,CAAC;AAElH,MAAsB,gBAAgB;IAC7B,MAAM,CAAkB;IAE/B,YAAY,MAAuB;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM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,EAAE,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAExF,OAAO,IAAA,mBAAU,EAAC,QAAQ,CAAC,KAAK,IAAA,mBAAU,EAAC,gBAAgB,CAAC,CAAC;IAC/D,CAAC;CACF;AA9ED,4CA8EC"} \ No newline at end of file diff --git a/src/offchain/typed-data-handler.ts b/src/offchain/typed-data-handler.ts index 0863c5a..cdf4d82 100644 --- a/src/offchain/typed-data-handler.ts +++ b/src/offchain/typed-data-handler.ts @@ -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)) { diff --git a/test/test/eas.ts b/test/test/eas.ts index becd3a3..f3eef51 100644 --- a/test/test/eas.ts +++ b/test/test/eas.ts @@ -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( @@ -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, diff --git a/test/test/helpers/custom-offchain.ts b/test/test/helpers/custom-offchain.ts index e547359..ff9ff20 100644 --- a/test/test/helpers/custom-offchain.ts +++ b/test/test/helpers/custom-offchain.ts @@ -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 }; } }