DisposableGuard

AWS Cognito

// Lambda: Pre Sign-up trigger
const https = require('https');

function checkDisposable(email) {
  return new Promise((resolve, reject) => {
    const url = new URL('https://api.disposableguard.com/v1/check');
    url.searchParams.set('email', email);

    const req = https.get(url.toString(), {
      headers: { Authorization: `Bearer ${process.env.DG_KEY}` },
    }, (res) => {
      let data = '';
      res.on('data', (chunk) => data += chunk);
      res.on('end', () => {
        try {
          resolve(JSON.parse(data).is_disposable === true);
        } catch {
          resolve(false); // fail-open
        }
      });
    });
    req.on('error', () => resolve(false)); // fail-open
  });
}

exports.handler = async (event) => {
  const email = event.request.userAttributes.email;
  if (await checkDisposable(email)) {
    throw new Error('Please use a real email address.');
  }
  return event;
};

Notes

Deploy as a Lambda function and attach as a Pre Sign-up trigger in the Cognito User Pool.