Files
neuron-web/src/js/account-auth.el
T
Will Anderson 94f6e749a0 Add El source files for all client-side JS
Recovers original JS from git history and ports it into proper El source
files under src/js/. Each file wraps the original JS in a native_js call
inside a main() function, making it valid El that compiles to a
self-contained IIFE via elc --target=js --bundle.

Files added:
  src/js/account-auth.el       - Supabase OTP magic-link (sendMagicLink)
  src/js/account-dashboard.el  - Account dashboard: session, plan card, family
  src/js/chat-widget.el        - Demo chat widget (neuronDemoToggle/Send/Reset)
  src/js/checkout-auth.el      - Checkout auth: OAuth, email sign-in/up
  src/js/checkout-free.el      - Free plan: auth-badge watch -> payment reveal
  src/js/checkout-stripe.el    - Stripe Payment Element (reads NEURON_CFG)
  src/js/enterprise.el         - Enterprise inquiry form + headcount filter
  src/js/environmental.el      - Efficiency calculator slider
  src/js/gallery.el            - Gallery nav, search/sort, Supabase voting
  src/js/main.el               - Share page voting + copyForPlatform
  src/js/marketplace.el        - Developer interest form
  src/js/nav.el                - Nav hamburger + Mission dropdown
  src/js/styles.el             - Landing: nav scroll, reveal, founding counter
2026-05-04 11:23:21 -05:00

41 lines
1.5 KiB
EmacsLisp

// account-auth.el -- Supabase OTP magic-link auth for the account page.
// Sends a PKCE magic link to the user's email address.
// Compiled with: elc --target=js --bundle --minify --obfuscate
//
// Required HTML elements: #acct-email-input, #acct-magic-btn, #acct-email-msg
// Required globals: window.NEURON_CFG.supabase_url, window.NEURON_CFG.supabase_anon_key
// Required CDN: supabase-js@2 loaded before this script
fn main() -> Void {
native_js("(function() {
'use strict';
var cfg = window.NEURON_CFG || {};
var sb = supabase.createClient(cfg.supabase_url, cfg.supabase_anon_key, {
auth: { flowType: 'pkce' }
});
window.sendMagicLink = async function() {
var email = (document.getElementById('acct-email-input').value || '').trim();
var msgEl = document.getElementById('acct-email-msg');
var btn = document.getElementById('acct-magic-btn');
if (!email) {
msgEl.style.display = 'block';
msgEl.style.color = '#c44';
msgEl.textContent = 'Please enter your email address.';
return;
}
if (btn) { btn.disabled = true; btn.textContent = 'Sending...'; }
var result = await sb.auth.signInWithOtp({ email: email });
if (btn) { btn.disabled = false; btn.textContent = 'Continue with email'; }
msgEl.style.display = 'block';
if (result.error) {
msgEl.style.color = '#c44';
msgEl.textContent = result.error.message;
} else {
msgEl.style.color = 'var(--navy)';
msgEl.textContent = 'Check your inbox — we sent a sign-in link to ' + email + '.';
}
};
})()")
}