diff --git a/src/config.ts b/src/config.ts index 793ccb9..a6fae0c 100644 --- a/src/config.ts +++ b/src/config.ts @@ -28,6 +28,9 @@ const ETH_REGISTRY_ABI = [ // response timeout: 1 min const RESPONSE_TIMEOUT = 60 * 1000; +// avatar cannot be greater than 50mb +const MAX_CONTENT_LENGTH = 50000000; + export { ADDRESS_ETH_REGISTRAR, ADDRESS_ETH_REGISTRY, @@ -39,6 +42,7 @@ export { INAMEWRAPPER, IPFS_GATEWAY, INFURA_API_KEY, + MAX_CONTENT_LENGTH, RESPONSE_TIMEOUT, SERVER_URL, }; diff --git a/src/service/avatar.ts b/src/service/avatar.ts index 95dc323..a992081 100644 --- a/src/service/avatar.ts +++ b/src/service/avatar.ts @@ -8,7 +8,7 @@ import { RetrieveURIFailed, TextRecordNotFound, } from '../base'; -import { IPFS_GATEWAY } from '../config'; +import { IPFS_GATEWAY, MAX_CONTENT_LENGTH } from '../config'; const window = new JSDOM('').window; @@ -75,7 +75,7 @@ export class AvatarMetadata { } if (avatarURI?.startsWith('http')) { - const response = await fetch(avatarURI); + const response = await fetch(avatarURI, { size: MAX_CONTENT_LENGTH }); assert(response, 'Response is empty');