Inbox created
- Forward OTP emails to
zjn7bcnirrbhy4u6zd@opensurf.io - Worker extracts code and stores for 60s
- Fetch it with a read-once API key
Keys
Inbox key
zjn7bcnirrbhy4u6zd
API key
9ED5wbBOBxWHPVNjLfWphaAn6vMXRGbf1HpPyw9rCM4
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 = '9ED5wbBOBxWHPVNjLfWphaAn6vMXRGbf1HpPyw9rCM4';
const inbox = 'zjn7bcnirrbhy4u6zd';
console.log('Waiting for code...');
const code = await waitForCode(key, inbox);
console.log(code);