Inbox created

  1. Forward OTP emails to ylqwiw6rxcbqkds4uc@opensurf.io
  2. Worker extracts code and stores for 60s
  3. Fetch it with a read-once API key

Keys

Inbox key

ylqwiw6rxcbqkds4uc

API key

piVqli3nsD8rfmK0FrWoYhWir-LJgcX3mF2sX0Iav68

TypeScript quickstart

async function fetchCode(key: string, inbox: string, sender = '') {
  const url = `https://opensurf.io/inbox/${inbox}/otp?sender=${sender}`;
  const res = await fetch(url, { headers: { Authorization: `Bearer ${key}` } });
  return res.json().catch(() => null);
}

async function waitForCode(key: string, inbox: string, sender = '') {
  while (true) {
    const code = await fetchCode(key, inbox, sender);
    if (code) {
      return code;
    }
    await new Promise((resolve) => setTimeout(resolve, 1000));
  }
}

const key = 'piVqli3nsD8rfmK0FrWoYhWir-LJgcX3mF2sX0Iav68';
const inbox = 'ylqwiw6rxcbqkds4uc';
console.log('Waiting for code...');
const code = await waitForCode(key, inbox);
console.log(code);