Welcome to HRKey

Build your verified professional profile

πŸŽ‰ Thanks for providing a reference!

You've seen how HRKey works. Now create your own profile and start building your decentralized professional reputation with blockchain-verified references.

We’ll send a magic link to your email to sign in securely (no password required).
OR
βœ…1 free blockchain-verified reference
⚑Setup in less than 2 minutes
πŸ”Secure & decentralized profile
🌐Share with employers worldwide
const url = new URL(window.location.href); // ===== REFEREE BANNER ===== const refereeInfo = localStorage.getItem("hrkey_referee_info"); if (refereeInfo) { try { const data = JSON.parse(refereeInfo); if (data.hasProvidedReference) { document.getElementById("refereeBanner").classList.add("active"); document.getElementById("headerSubtitle").textContent = "Now build your own verified profile!"; } } catch {} } // ===== CALLBACK HANDLING (OAuth + Magic Link) ===== // If Supabase returns with ?code=..., exchange it for a session const code = url.searchParams.get("code"); const errorDesc = url.searchParams.get("error_description"); if (errorDesc) console.error("Auth error:", errorDesc); if (code) { try { // In supabase-js v2 this reads the code from the URL. const { error } = await supabase.auth.exchangeCodeForSession(window.location.href); if (error) { console.error("exchangeCodeForSession error:", error); } else { const next = url.searchParams.get("next") || "/WebDapp/app.html"; // Clean the URL but keep the correct path const cleanUrl = `${window.location.origin}/WebDapp/auth.html`; history.replaceState({}, document.title, cleanUrl); // Debug: show token in console const { data } = await supabase.auth.getSession(); console.log("βœ… session after exchange:", data?.session); console.log("βœ… access_token:", data?.session?.access_token); window.location.replace(next); } } catch (e) { console.error("Exchange failed:", e); } } else { // If already logged in, go to app const { data } = await supabase.auth.getSession(); if (data?.session) { console.log("Already logged in:", data.session.user?.email); window.location.replace("/WebDapp/app.html"); } } // ===== FORM HANDLER (Magic Link) ===== const form = document.getElementById("authForm"); const submitBtn = document.getElementById("submitBtn"); if (form && submitBtn) { form.addEventListener("submit", async (e) => { e.preventDefault(); const name = document.getElementById("name")?.value?.trim() || ""; const email = document.getElementById("email")?.value?.trim() || ""; if (!name || !email) { alert("Please enter your name and email."); return; } submitBtn.disabled = true; const old = submitBtn.textContent; submitBtn.textContent = "⏳ Sending magic link..."; // Keep your local β€œprofile” seed const userData = { name, email, wallet: "0x" + Math.random().toString(16).slice(2).padEnd(40, "0"), authenticated: false, loginDate: new Date().toISOString(), source: refereeInfo ? "referee_conversion" : "direct_signup" }; localStorage.setItem("hrkey_user_data", JSON.stringify(userData)); localStorage.setItem("hrkey_user_plan", JSON.stringify({ plan: "free", features: { maxReferences: 1, canUseBlockchain: false, canExportPDF: false }, usage: { referencesUsed: 0 } })); try { // Send magic link (creates/uses a Supabase user identity) const redirectTo = `${window.location.origin}/WebDapp/auth.html?next=/WebDapp/app.html`; const { error } = await supabase.auth.signInWithOtp({ email, options: { emailRedirectTo: redirectTo } }); if (error) throw error; alert("βœ… Check your email for the magic link to finish signing in."); submitBtn.textContent = old; } catch (err) { console.error("Magic link error:", err); alert("Error sending magic link: " + (err?.message || "Unknown error")); submitBtn.textContent = old; } finally { submitBtn.disabled = false; } }); } // ===== GOOGLE OAUTH ===== const googleBtn = document.getElementById("googleBtn"); if (googleBtn) { googleBtn.addEventListener("click", async () => { googleBtn.disabled = true; googleBtn.textContent = "⏳ Connecting to Google..."; try { const redirectTo = `${window.location.origin}/WebDapp/auth.html`; const params = new URLSearchParams(); params.set("next", "/WebDapp/app.html"); const finalRedirect = params.toString() ? `${redirectTo}?${params.toString()}` : redirectTo; const { error } = await supabase.auth.signInWithOAuth({ provider: 'google', options: { redirectTo: finalRedirect } }); if (error) { console.error("Google OAuth error:", error); alert("Error connecting with Google: " + error.message); googleBtn.textContent = "πŸ” Continue with Google"; googleBtn.disabled = false; } } catch (e) { console.error("Google OAuth failed:", e); alert("Failed to connect with Google"); googleBtn.textContent = "πŸ” Continue with Google"; googleBtn.disabled = false; } }); } // ===== WALLET AUTHENTICATION ===== import("./js/wallet-connector.js").then(module => { const { connectMetaMask, connectCoinbaseWallet, connectWalletConnect } = module; const metamaskBtn = document.getElementById("metamaskBtn"); if (metamaskBtn) { metamaskBtn.addEventListener("click", async () => { metamaskBtn.disabled = true; metamaskBtn.textContent = "⏳ Connecting to MetaMask..."; try { await connectMetaMask(refereeInfo); } catch (err) { console.error("MetaMask connection error:", err); alert("Failed to connect with MetaMask: " + (err?.message || "Unknown error")); metamaskBtn.disabled = false; metamaskBtn.textContent = "🦊 Connect with MetaMask"; } }); } const coinbaseBtn = document.getElementById("coinbaseBtn"); if (coinbaseBtn) { coinbaseBtn.addEventListener("click", async () => { coinbaseBtn.disabled = true; coinbaseBtn.textContent = "⏳ Connecting to Coinbase Wallet..."; try { await connectCoinbaseWallet(refereeInfo); } catch (err) { console.error("Coinbase Wallet connection error:", err); alert("Failed to connect with Coinbase Wallet: " + (err?.message || "Unknown error")); coinbaseBtn.disabled = false; coinbaseBtn.textContent = "πŸ”΅ Connect with Coinbase Wallet"; } }); } const walletconnectBtn = document.getElementById("walletconnectBtn"); if (walletconnectBtn) { walletconnectBtn.addEventListener("click", async () => { walletconnectBtn.disabled = true; walletconnectBtn.textContent = "⏳ Connecting to WalletConnect..."; try { await connectWalletConnect(refereeInfo); } catch (err) { console.error("WalletConnect connection error:", err); alert("Failed to connect with WalletConnect: " + (err?.message || "Unknown error")); walletconnectBtn.disabled = false; walletconnectBtn.textContent = "πŸ”— Connect with WalletConnect"; } }); } }).catch(err => { console.error("Failed to load wallet connector:", err); });